Lurker News
I tend to always look to api.github.com when I need a little inspiration.

Anyone have some good examples of a particularly well laid out API?

Comments (182) 67 threads

Earlier comments
bryanlarsen3 replies#
Related: anybody have some good examples of a good asynchronous API? This claims to be the standard, but it has confused many of our customers. http://restcookbook.com/Resources/asynchroneous-operations/

To summarize: send a 202 for the initial request, redirecting to a job URL. The client polls on the job URL, which returns 200 with progress information until it's done, when it returns a 303 redirecting to the final output.
One particular problem spot is that many http libraries automatically follow the 303 redirect, and some even follow the 202 redirect.
I definitely think we would have been better off just putting status and final location information as JSON attributes in the body rather than putting it in HTTP response codes and Location headers. Non-standard, but much less confusing for our customers.

infinite8s3 replies#
If you have to poll then it's not asynchronous. A better design would utilize something like webhooks.
bryanlarsen#
Yes, we have webhooks, and a grand total of 1 of our customers uses them. Setting up an HTTP server just to receive a webhook is a lot to ask.

Long poll lets the polling be efficient.

bjt#
> If you have to poll then it's not asynchronous.

Says who?
Maybe not "streaming". Maybe not "real time". But certainly asynchronous.

kasey_junk1 reply#
All push models are poll models down an abstraction layer.
infinite8s1 reply#
And all computations can be modeled as Universal Turing Machines at some level. That doesn't mean it's the most useful level at which to analyze the semantics of what you are trying to accomplish.

Continue this thread — 1 reply

mmalone#
The short answer is that there is really no good general purpose way to deal with asynchronous communication in a "restful" HTTP API. All solutions have major drawbacks. This is one of the biggest shortfalls of rest/http in my experience. People tend to switch to other protocols to address these use cases (this is a common reason for adopting message bus infrastructure like Kafka as part of a SOA).
dxhdr#
I think it could use improvement. Look at https://api.slack.com/methods/chat.postMessage and explain how "as_user" makes any sense. And it gets more convoluted depending on other parameters used (IM channels, etc.)

Also, why can't I use a secret key with my basic postMessage script? I have to navigate OAuth2 just to make a post? Argh the pain!

huherto6 replies#
Follow up. Anyone care to recommend a good book or reference on good design of REST APIs?
amjd#
I can vouch for this. It really helped me when I was getting started with REST APIs.
specialist1 reply#
+1, if you have to do REST, this is the book.

Our book study group covered this book a few years ago. This book is rational, its advice actionable.
Like "Agile", "REST" is merely a pretext to start an argument. Just do what works, focusing on reducing the cost of change (risk mitigation).

rimantas1 reply#
Which one? There are three listed.

Continue this thread — 1 reply

mcobrien#
I read this after patio11 linked to it. It's an amazing resource, thank you!
specialist#
Well done. I opened your link, expecting more banal hand waving dogma. Instead, I found myself nodding agreement with most items in your list. Thank you.
cyberferret#
+1 for Vinay's post on API design. I came across it a few months ago and it was a brilliant checklist/guide for us developing an API for our web app.
josh_carterPDX#
Thank you for posting this. Awesome!
phamilton#
Make sure to read the Fielding Dissertation to understand what REST actually is.
supergeek1331 reply#
Twilio does a pretty good job as well.
w00kash2 replies#
Just curious. What do you think it is that makes twilio a good example of a REST API? Other than the fact that they have one?
taf2#
It used to always be cited as an example of a good REST API see this same question from 7 years ago and you'll see Twilio is top recommended https://news.ycombinator.com/item?id=867972

Oh and still is today because it's a good API - timeless

supergeek133#
From a development perspective it isn't so much the actual API or the structure of it.. but how easy they make it to understand and integrate into it.

They have a plethora of getting started guides and examples that make it really easy to 'hello world' quickly.
You have to actually dig to get to the reference when you first sign up.
Hello world in 30 minutes or less is important for any API program.

Load more comments