Wednesday, February 08, 2012

How I learned to stop worrying and love REST - Mike Mayo

How I learned to stop worrying and love REST - Mike Mayo: "In that podcast they mentioned that one of the core points of REST is that the resources should provide the means to traverse the API. Think of it like links on a webpage; we don’t expect the user to know our URL format and manually type it in when they want to view the next link. Instead we provide them hyperlinks so they can easily traverse our sites. A REST API should function the same way; when you provide someone a list of JSON objects, you should also provide the URI to access each of those objects, or, in the case of my pagination example, the URI to retrieve the next page of results. To quote Roy Fielding:

A REST API should be entered with no prior knowledge beyond the initial URI (bookmark) and set of standardized media types that are appropriate for the intended audience (i.e., expected to be understood by any client that might use the API). From that point on, all application state transitions must be driven by client selection of server-provided choices that are present in the received representations or implied by the user’s manipulation of those representations. 1"

'via Blog this'