I'm Brett Slatkin and this is where I write about programming and related topics. Check out my favorite posts if you're new to this site. You can also contact me here or view my projects.

01 September 2013

RESTful Do's and Don'ts

In that same post someone asked Roy Fielding how to implement a distributed queue with REST. His reply clarifies best practices (emphasis mine):

A distributed queue is an implementation choice. You can certainly implement some applications by having them interact with a queue-like resource in a RESTful manner. However, if your client relies on the resource being a queue, then it certainly isn’t a RESTful API. Do you see the difference? Encoding knowledge within clients and servers of the other side’s implementation mechanism is what we are trying to avoid.

If a client is receiving instructions on how to interact with a resource just before acting only on those instructions, then the client doesn’t care if the resource is a distributed queue. It simply doesn’t need to know how the resource is implemented. All it needs to know is the meaning of those instructions and some idea of what it wants to do next, whether that purpose be user-driven, configuration-driven, or some sort of AI-driven.

REST starts with discovery, not verbs. Roy's concern here is hypertext for API actions. The goal is eliminating hidden assumptions in API clients.
© 2009-2016 Brett Slatkin