Ask HN: What is your go-to example for a good REST API?
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?
Anyone have some good examples of a particularly well laid out API?
188 comments
[ 5.3 ms ] story [ 241 ms ] threadGood error handling, easy to get started, and they provide Postman collections for each API
One nitpick: it always feel weird to me to have an error (or any other object) where the attributes are named like this:
Why have "error" in there at all?https://stripe.com/docs/api
I dislike Stripe's API. There are parts of it that just make no sense.
Say, you want to set a billing date for that fancy subscription. Yeah, just set a trial date until the billing date you want. Oh, and don't forget to charge a prorated difference (by hand, with charges)!
Want to upgrade that subscription? Yeah, cancel that subscription and start a new one. Oh, and don't forget to set that trial again!
Want to cancel that subscription but not until their next billing date? Hahaha, yeah no. You need to cancel now through Stripe and set up a process to cancel on your side. (Not the biggest complaint, but really. If I am having Stripe manage my subscriptions, they should do it all)
And I am sure there are many other details which would also drive me mad.
With all of that said, I think Stripe's API is definitely one of the better ones since my complaints are more functionality / feature requests than complaints about how it is set up.
My advice when starting a SaaS company: think through your subscription software early on, before it's a headache to even think about migrating away.
And what do you mean "upgrade"? You can move from one plan to the next and charges are pro-rated automatically for you.
I, too, loath the amount of time we've spent on subscription/billing but I'm just surprised that none of the issues you've listed are really causing any pain for us.
Although it’s kind of proving your point that the API could be easier to use/better documented, here are some simpler ways to do what you’re looking for:
* Upgrading a plan (no cancellation needed): https://stripe.com/docs/api#update_subscription-plan
* Canceling a subscription at the end of the billing cycle (no need to handle on your end): https://stripe.com/docs/api#update_subscription-at_period_en... * Anchoring subscription to a date (sorry! :( , this is undocumented but should be out soon): https://stripe.com/docs/api#create_subscription That said, agreed overall that our subscriptions support needs some love. We're starting to spend more time on exactly this, so would love any feedback you (or anyone else reading) are willing to share. I'm eduardo@stripe.com.- https://stripe.com/docs/subscriptions/guide
Thank you so much for the response! Complaining on the internet finally worked! :) I definitely hold nothing against Stripe, I still love you guys.
And why are there separate clients for Java and Android, which both use the same namespace differently?
And why do I need to set the API key as a global for the general Java client, while the Android client (sensibly) lets me give it as a constructor argument?
What do you mean by "Leaks the JSON structure of the document to the client"?
Some parts are great, other parts not so much. My thoughts echo the other's here.
It seems like the API is way too complex to do certain operations. Especially some very common use cases: for example, how to apply discount for next year for customers who already have subscription (we wanted to emulate how Comcast always gives you discount if you want cancel and took us weeks to make that working ...). I think they do want to fix all these issues but API is not designed to be easily expandable.
It's actually very hard to find a decent REST API :(
My points here are the following:
1. Think very very hard about how people will use your API <-- this is critical. This also includes operational characteristics of your API (performances, how often it is going to be called, optimization, etc.)
2. Make API easily expendable. Especially relationships between models. Sometimes, it is ok (or even better) just to organize it as "SQL wrapper". Like SOQL by Salesforce - but that again depends on number 1.
Also, what's up, homie? Hope you're well.
http://apigee.com/about/resources/ebooks/web-api-design
1. https://www.amazon.com/REST-Practice-Hypermedia-Systems-Arch...
2. https://www.amazon.com/Building-Hypermedia-APIs-HTML5-Node/d...
3. http://www.designinghypermediaapis.com/
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).
The examples are PHP-based and there is an active Slack channel supporting the book.
http://www.vinaysahni.com/best-practices-for-a-pragmatic-res...
https://developers.google.com/drive/v2/reference/#Children
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.
Long poll lets the polling be efficient.
Says who?
Maybe not "streaming". Maybe not "real time". But certainly asynchronous.
[1] https://developers.digitalocean.com/documentation/v2/
Typically when a company refuses to say their price or says "Contact Us", that means "Prepare your wallets".
With that said, very economical. I think it was something like $0.10 per account you add. I am looking forward to Plaid expanding what banks are offered since currently they only work with 10 or so (although if they pick you, they give you access to a few thousand more. Not sure the criteria)
If you have any other questions, feel free to reach me directly at charley@plaid
You were very helpful! I am looking forward to having access to more banks! (If that is in the plan)
This, so much. Especially when it is a developer tool, where the switching cost is high because other software sits on top of it.
They're due to get hit with a nasty suit regarding fraud.
https://api.slack.com/
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!
Oh and still is today because it's a good API - timeless
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.
I've seen "OData" mentioned here and there, but I've never understood the difference between OData and a classic REST API.
Excel is a nice example, you can have a sheet with data pulled in over odata from any app that supports odata.
A lot has been written on API design that makes for interesting reading.
(By internal interface I mean: an interface that is used only by the team that created it)
https://developers.digitalocean.com/documentation/v2/