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

Show all comments

Showing thread 9 of 67

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).