21 Resources are mapped to URLs
Actions are mapped to verbs
The rest goes in the headers Resources are mapped to URIs
Actions are mapped to verbs
The rest goes in the headers
26 You want to say “Happy Birthday” on some social network.
Option A
Go directly to friend’s page and post. Option B
Go to Homepage > search friend > post. What if…
27 Then… Why shouldn’t you do the same for APIs? > GET /apis < Content: ! apis: [ { path: "/presentations/", description: "IPNLis thematic presentations" }, { path: "/pizzas/", description: "Pizza for the presentations" }, ]
28 That’s hypermedia! Actually, it’s called HATEOAS. Hypermedia
as
the
Engine
of
Application
State - Single endpoint for the resource
- All actions discovered by inspecting resource
29 HATEOAS Get a certain keynote: presentation: { id: 1337, name: "All About APIs", date: "2013-03-12", authors: { path: "/presentations/1337/authors/", description: "Keynote’s authors", } } We know what to do next ☺
30 HATEOAS Get all the keynotes: presentations: [ {...}, ... {...} ], Meta: { total: 100, paginated_objects: 25, next_page: "/presentations?offset=25" } }25 presentations Where to get some more
- Version a resource representation, not the API
-Add a new version when the changes in the resource representation are non-backward compatible First of all 32
• Publishing of metadata along with querysets • proper HTTP response handling • posting of data with validation • serialization • API discovery • throttling • permissions • authentication • pagination 47