News for hackers. Stuff that matters.
Re:Ask HN: What is your go-to example for a good REST API? by sc00ty on Friday June 24, 2016 @02:53PM (#11972414)
Stripe. Their docs are amazing too, I always find it a pleasure integrating their API.

https://stripe.com/docs/api

Re:Ask HN: What is your go-to example for a good REST API? by madelinecameron on Friday June 24, 2016 @05:06PM (#11973480)
Nooooooooo.

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.

Re:Ask HN: What is your go-to example for a good REST API? by guayosr on Friday June 24, 2016 @08:27PM (#11974551)
(I work at Stripe.)

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

  > `curl https://api.stripe.com/v1/subscriptions/sub_foo -u sk_test_bar: -d plan={new_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...

  > `curl https://api.stripe.com/v1/subscriptions/sub_foo -u sk_test_bar: -X DELETE -d at_period_end=true`
* Anchoring subscription to a date (sorry! :( , this is undocumented but should be out soon): https://stripe.com/docs/api#create_subscription

  > `curl https://api.stripe.com/v1/subscriptions/sub_foo -u sk_test_bar: -d billing_cycle_anchor={timestamp}`
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 [email protected].
Re:Ask HN: What is your go-to example for a good REST API? by madelinecameron on Saturday June 25, 2016 @05:44PM (#11978134)
No way!

Thank you so much for the response! Complaining on the internet finally worked! :) I definitely hold nothing against Stripe, I still love you guys.

Re:Ask HN: What is your go-to example for a good REST API? by leesalminen on Friday June 24, 2016 @08:56PM (#11974640)
Thanks Eduardo. I've interacted with you (I think) a couple times and really appreciate the effort you all put into customer outreach. It is appreciated. I will have my team jot down thoughts on subscription functionality and send it over.
Re:Ask HN: What is your go-to example for a good REST API? by hoodoof on Friday June 24, 2016 @08:29PM (#11974558)
Is this in an obvious place in the docs or in an FAQ?
Re:Ask HN: What is your go-to example for a good REST API? by guayosr on Friday June 24, 2016 @08:33PM (#11974576)
Re:Ask HN: What is your go-to example for a good REST API? by Lordarminius on Saturday July 02, 2016 @08:50AM (#12022290)
Stripe is quite good
Re:Ask HN: What is your go-to example for a good REST API? by leesalminen on Friday June 24, 2016 @05:36PM (#11973683)
I agree. Their subscription functionality is half-baked. We're 2 years into using Stripe for subscription management and it's such a hassle to move anywhere else that we keep hobbling along with it.

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.

Re:Ask HN: What is your go-to example for a good REST API? by Nullabillity on Saturday June 25, 2016 @07:10AM (#11975953)
Also, the provided Java client is garbage (you need to put all the arguments into an untyped hashmap that corresponds to the JSON, WTF?).

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?

Re:Ask HN: What is your go-to example for a good REST API? by elwell on Friday June 24, 2016 @10:54PM (#11974973)
I opted to just roll my own subscription system and use normal charges periodically as needed.
Re:Ask HN: What is your go-to example for a good REST API? by marcusbrown on Saturday June 25, 2016 @05:08PM (#11978000)
I recently used Laravel Spark [ https://spark.laravel.com/ ] to manage all the subscriptions and I really love it! Before I had to do it all by myself and it was a nightmare and so much time taken away to develop the real app. I highly recomment it for any SaaS product. It gives you a huge jumpstart and you can concentrate on developing just your app. Btw, it supports both Stripe and Braintree.
Re:Ask HN: What is your go-to example for a good REST API? by mooreds on Friday June 24, 2016 @11:28PM (#11975065)
I did that too, mostly because I am splitting transactions to connected accounts and subscriptions don't play nicely with that functionality, according to the docs.
Re:Ask HN: What is your go-to example for a good REST API? by encoderer on Friday June 24, 2016 @06:51PM (#11974113)
So you want to set a billing date and then charge a pro-rated amount that first month?

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.

Re:Ask HN: What is your go-to example for a good REST API? by tlogan on Saturday June 25, 2016 @03:05AM (#11975526)
Sadly, Stripe API is not so great :(

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.

Re:Ask HN: What is your go-to example for a good REST API? by jxm262 on Friday June 24, 2016 @03:02PM (#11972478)
^ Came in to say this. I use Stripe for inspiration on their API, docs, and even the general UI/UX to get a feel for something simple yet elegant.
Re:Ask HN: What is your go-to example for a good REST API? by mrgalaxy on Friday June 24, 2016 @05:47PM (#11973756)
Jeez, glad I'm not the only who feels Stripe's API is basically the golden standard when it comes to a properly implemented REST API and documentation.
Re:Ask HN: What is your go-to example for a good REST API? by bparanj on Friday June 24, 2016 @05:24PM (#11973602)
-1 for Stripe. The API is designed without any thought how the use cases need to use it. Leaks the JSON structure of the document to the client. This breaks your code when they change the JSON structure.
Re:Ask HN: What is your go-to example for a good REST API? by nfm on Friday June 24, 2016 @07:24PM (#11974267)
I'm not sure what you mean about changing the JSON structure; the Stripe API is versioned and you have to opt-in to any updates, including breaking changes like removing or renaming keys in the response.
Re:Ask HN: What is your go-to example for a good REST API? by kornish on Friday June 24, 2016 @07:20PM (#11974245)
Well, all code depending on JSON presumably breaks when that JSON changes. That's what versioning is for.

What do you mean by "Leaks the JSON structure of the document to the client"?

Re:Ask HN: What is your go-to example for a good REST API? by ciq_steve on Friday June 24, 2016 @10:23PM (#11974894)
Even better is the realtime support on their IRC channel.
Re:Ask HN: What is your go-to example for a good REST API? by iLoch on Friday June 24, 2016 @04:13PM (#11973074)
+1 for Stripe. BlockScore is another one similar to Stripe in terms of docs and intuitive design.
Re:Ask HN: What is your go-to example for a good REST API? by BlackjackCF on Friday June 24, 2016 @06:13PM (#11973914)
I feel like their API isn't super uniform in a lot of the ways it's integrated, but I will give them a +1 for allowing very easy versioning.
Re:Ask HN: What is your go-to example for a good REST API? by jdc0589 on Friday June 24, 2016 @03:48PM (#11972863)
nit picking devil's advocate: not all of the API is documented. There are some features that exists, but you have to know about. Granted, this is intentional. e.g.: "billing_cycle_anchor" in the subscription API.
Re:Ask HN: What is your go-to example for a good REST API? by joshmn on Friday June 24, 2016 @05:40PM (#11973714)
+0.

Some parts are great, other parts not so much. My thoughts echo the other's here.