Live data from Hacker News

APIs as infrastructure: future-proofing Stripe with versioning

stripe.com

1–10 of 53 posts

Re: APIs as infrastructure: future-proofing Stripe with versioning

#2
Thank you to Stripe for the efforts they make in this area. If you're building critical infrastructure around someone else's system -- and it doesn't get much more critical than the way you collect money -- then you really want this kind of stability.

I wish other payment services treated their long-time clients with the same respect (looking straight at you, GoCardless).

Re: APIs as infrastructure: future-proofing Stripe with versioning

#3
To me this is one of the best things about the Stripe API. It's basically database migration files but for your API requests.

Does anyone know of packages that do this already? I have been contemplating creating one in PHP/Laravel for a long time but haven't had the time yet...

Re: APIs as infrastructure: future-proofing Stripe with versioning

#4
I work on a SOA team at a large healthcare enterprise. We currently write mostly SOAP APIs (yeah, I know, 2017 and all that...), and follow a typical pattern as what Stripe describes: Whenever we do a version bump (which is extremely frequent, since a WSDL breaks a contract the moment you sneeze at it), we create an XSLT transform from the new version back to the old. So if you're calling version 2, but the current version is 10, there will be transforms back for 10->9, 9->8, 8->7... all the way back to 2. It works well enough.

We're in the early stages of deploying a new RESTful stack, and versioning is a hot topic (along with getting people out of the RPC mindset and into a resource-based paradigm). While version bumps should be much less common, we'll probably end up doing something similar to our cascading transformations. Essentially, the old version becomes a consumer of the new version, and as long as the new version continues to hold to its API contract, everything should work with minimal fuss. Of course, that's assuming that we don't change the behavior of a service in ways that aren't explicitly defined in the API contract...

Re: APIs as infrastructure: future-proofing Stripe with versioning

#5
This is awesome. As someone who's built many APIs, I have always wondered how Stripe managed all those versions. I knew their code couldn't just be littered with if/thens.

This is a really smart way to do it.

One question is, over the years, wouldn't you add a lot of overhead to each request in transformation? Or do you have a policy where you expire versions that are more than 2 years old, etc? (skimmed through parts of the article so my apologies if you already answered this)

Re: APIs as infrastructure: future-proofing Stripe with versioning

#6
That's a great system - I'm totally going to borrow that technique when it next makes sense.

Hey, @pc with all the spare time your team has accumulated by using this api model maybe you could put it to good use. Might I suggest it's time to divert most of your tech resources into creating the next Capture the Flag? Because those were just awesome!

I'm joking, in case it's not obvious (but I would absolutely love another Stripe CTF).

Re: APIs as infrastructure: future-proofing Stripe with versioning

#7
Most excellent write-up. I used Stripe for inspiration when writing a post that wound up here titled 'Pragmatic API Versioning', since been renamed 'How to Version a Web API'. It felt like the most clever way to reconcile change and stability, when compared to other major APIs.

It was a delight to get a peek behind the curtain. :)

Re: APIs as infrastructure: future-proofing Stripe with versioning

#8
I'm working on designing an API now that is based on Stripe's previous post from how they do versioning.

In general, the concepts employed by Stripe really encourage better design choices. All changes, responses, request parameters, etc should be documented and then handled automatically by the system. We took this approach in our design, although we don't do it with an explicit "ChangeObject" like Stripe does; it's a great idea though.

Hoping to be able to put out a blog post once we start implementing the system and getting feedback on what works and doesn't work well.

Re: APIs as infrastructure: future-proofing Stripe with versioning

#9
Always excited to hear Stripe talking about versioning :D

For anyone else who's interested, they've written/talked about this a few times over the years, to fill out the picture:

- http://amberonrails.com/move-fast-dont-break-your-api/

- https://www.heavybit.com/library/video/move-fast-dont-break-...

- https://speakerdeck.com/apistrat/api-versioning-at-stripe

- https://brandur.org/api-upgrades

- https://news.ycombinator.com/item?id=13708927

It sounds like their YAML system has changed to be implemented in code instead, which maybe allows the transforms to be a bit more helpful/encapsulated. If anyone from Stripe is here, it would be awesome to know if that's true and why the switch?

Re: APIs as infrastructure: future-proofing Stripe with versioning

#10

I work on a SOA team at a large healthcare enterprise. We currently write mostly SOAP APIs (yeah, I know, 2017 and all that...), and follow a typical pattern as what Stripe describes: Whenever we do a version bump (which is extremely frequent, since a WSDL breaks a contract the moment you sneeze at it), we create an XSLT transform from the new version back to the old. So if you're calling version 2, but the current v…

[deleted]
Post reply on HN