Familiarity Breeds Contempt (Or why all APIs suck, even yours.)
1. Familiarity Breeds Contempt
Or why all APIs suck. Even yours.
Stephen Darlington
@sdarlington / @wandlesoftware
www.wandlesoftware.com / www.zx81.org.uk
6. What is an API?
• “An application programming interface, or
API, is the set of symbols that are
exported and available to the users of a
library to write their application.” (The Little Manual
of API Design)
• “The design of the APIs is arguably the
most critical part of designing the library”
7. What is an API?
• An interface used to communicate with
people
– Web service API
– A reusable Cocoa component
– List of functions in a header file
• “Other people” includes the “future you”
8. It’s easy to be a critic
“In many ways, the work of a critic is easy.
We risk very little, yet enjoy a position over
those who offer up their work and their
selves to our judgment. We thrive on
negative criticism, which is fun to write and
to read.”
Anton Ego, Food critic, Ratatouille
13. Using it – example 2
• Syncing Delicious.com bookmarks
• https://api.delicious.com/v1/posts/all
– hashes=
• https://api.delicious.com/v1/posts/get
– meta=yes
– hashes=
14. Using it – example 2
• You have to download all the “hashes”
– How many?
– How big?
• “hashes” means different things in different
commands
• Very long GET request
• Undocumented parameters
16. Let’s try to be positive…
• Don’t think “what’s the easiest way of
making all this data public?”
– Consider use-cases of clients
• Give it a REST
– Leave religion to the church. Make it work first
• Use your own API
– Don’t have “secret” methods
– Amazon are a great example
If changing it might cause someone pain, it’s pretty much an API for the purposes of this talk
If changing it might cause someone pain, it’s pretty much an API for the purposes of this talk
Documentation
Coming soon. Link to partial.
Inadequate to code against
No example.
Complete
Crap syncing
Think about your use cases
Error handling "something went wrong” (delicious)
Facebook API fails when no friends
GameCenter mysteriously fails when one user is connected on Simulator rather than a real device
Consistent way of accessing data. Example: when you add a URL, the URL that gets saved is not always the one you send (you’ve mentioned stripping out some of the Google Reader junk; Delicious “helpfully” converts “www.wandlesoftware.com” to “http://www.wandlesoftware.com”). The only way to have the offline copy up-to-date is by doing a complete sync again.
Tags is with commas… which they changed without any notice and without changing the rest of the API.
Mobile considerations:
Limited memory
Limited bandwidth
Potentially high latency
Unreliable
Really bad proxy servers
You need the = after “hashes”
If you want to allow syncing… why not have a “changes since DATE” function?
Allow “get all” but in “pages”
Versions
Upward compatibility
Spaces vs commas use same version
Adding new features, but keeping the same version (and not documenting it)
Notice period
Yahoo ID
Twitter oauth
The title of this talk is “Familiarity Breeds Contempt” for a reason. You need to *use* an API to really appreciate it – and almost anything you’ve used you find problems with. That doesn’t mean they’re all bad – it’s a spectrum – but you should aim to be at the right end of the spectrum.
Or at least, apps that are not as good as they could have been. The time I spend battling the API could have been better spent making the UI better or adding more features.