Later this year, Netflix will be closing their public APIs. Twitter and Google have already restricted their APIs. Despite prominent tech-companies making drastic changes to their APIs, the number of APIs keeps growing steadily. Suddenly, everyone has an API. Your car has one, Chuck Norris has one, and worst of all, tech-companies with no focus on quality whatsoever has one. And who are using these APIs? Most likely, no one.
This presentation will take you through the pitfalls of creating an API. From a developers perspective, what mistakes will result in no one wanting to use your API?
Live examples:
Download the Postman Chrome extension and import the following collections:
https://www.getpostman.com/collections/ede2ced9d83ddf66ba93
https://www.getpostman.com/collections/20c0047a17211caa631f
https://www.getpostman.com/collections/23bfb218456adb5c0a63
14. URI DESIGN
Badly named and inconsistent URIs that violate the
Principle of Least Astonishment will make your web API
just as disappointing as the movie "Mega Shark vs Giant
Octopus"
15. PRINCIPLE OF LEAST
ASTONISHMENT
"[...] a programmer should try to think of the
behavior that will least surprise someone
who uses the program, rather than that
behavior that is natural from knowing the
inner workings of the program."
16.
17. PROBLEM #1
INCONSISTENT URI STRUCTURE
We cannot guess the URI of an endpoint based on our
experience with the other endpoints.
18. PROBLEM #2
URIS ARE NOT HACKABLE
/all_links_for_city_of/chicago/il.json
/all_links_for_city_of/chicago/il.json
/all_links_for_city_of/chicago/il.json
24. SAFE METHODS
"... the convention has been established that
the GET and HEAD methods SHOULD NOT
have the significance of taking an action
other than retrieval. These methods ought
to be considered "safe"."
32. THE OTHER VERBS?
GET Returns the state of the sun roof (open/closed)
PUT Open/close the sunroof
POST Not supported, cannot create new sun roof
DELETE Not supported, cannot delete sun roof
46. VERSIONING
However perfect you make your web API, you're bound to
find a way that's even more perfect before long, and then
you'll need to launch a new version.