HTTP verbs describe the action that can be performed on the resource • Status codes describe the request outcome • Request type (or pseudo format in the URL) asks for a particular data representation in the response
resources available • If we get all the collection, the response can contain thousands of resources. Pagination means some custom API logic, and the client needs to be aware of it • Returned response does not have to include all children resources even though they may exist. Client needs to know about relationships between resources • If the URI changes, client needs to be updated accordingly • … • In summary: client needs to know a lot about the API on order to consume it, and most API changes require a client update It is NOT enough
Client has no prior knowledge on how to interact with the server • Can be easily parsed by the client • Client traverses the response to get deeper into the resource relationships • API can drive the state of the application
has subscriptions and preferences, and knows the URIs to access them • Combined with REST RFC knowledge, the consumer can now retrieve account preferences, get current subscriptions or update them
resources URIs by extracting href attribute of the corresponding rel Therefore URIs can change, relationships can be swapped and the whole API structure can change without the need to update the client As long as the client does not access URIs by direct URL and uses rel/href pair instead
to add a new resource of a type subscription to the given account, how does it know what data to send? JSON-Schema http://json-schema.org/latest/json-schema- hypermedia.html Note: There is no standard defining where JSON-Schema should go in RESTful APIs
introduce self-discovery into APIs • Self-documenting resource schema may be a pain but it will pay off in the future • There are a lot of missing or not-so-popular standards and that makes this self discovery movement much more problematic • Some good tendencies are in place, and the following are the proof: • https://developer.github.com/v3/ • Spring-Hateoas package for Java Spring Framework • In Python world there is REST Django framework built-in self-discovery • http://micro-api.org/ • http://jsonapi.org/ • https://developers.google.com/discovery/ • Nice libraries exist to automatically validate and parse JSON schema