News for hackers. Stuff that matters.
Re:APIs as infrastructure: future-proofing Stripe with versi... by michaelchisari on Tuesday August 15, 2017 @06:50PM (#15023455)
> Essentially, the old version becomes a consumer of the new version

As a raw concept, I really like this idea. Let's say you're bumping from 2.5 to 2.6 and there's a breaking change in-between.

You replace the old api code with a new thin layer that consumes 2.6 and puts it in 2.5 format. This would be easy to write a series of tests for to make sure that 2.5 is still providing what it should, and it has the added benefit of giving your engineers the opportunity to consume the new api internally in a structured way, so that would be a good way to catch any bugs you might not otherwise find.

And of course, the 2.4 version already only consumes the 2.5 version, so it's turtles all the way down.

That's a great concept. You would have to still deprecate APIs or provide an incentive for users to update to the newest version, otherwise the oldest versions would create a long chain of requests that add unnecessary overhead. But otherwise I love it.

Re:APIs as infrastructure: future-proofing Stripe with versi... by lifeisstillgood on Wednesday August 16, 2017 @12:40AM (#15024967)
Don't you mean the other way round? You always want to be running the most recent 2.6 servers, but when someone sends version 2.5 requests you transform the 2.5 to 2.6 and pass it along to your server (and vice Verda with responses)

The problem I guess is breaking changes come easily - it's fine if say we have example.com/homeaddress and now I add a zip code field in 2.6 - but a 2.5 request has no zip code and if 2.6 makes that mandatory it's really 3.0 - that just feels wrong. But it's a breaking change so, ok. But you get a deeper discussion then over why make a lack of zip code a breaking chnage ? Interesting

Re:APIs as infrastructure: future-proofing Stripe with versi... by michaelchisari on Wednesday August 16, 2017 @12:53AM (#15025023)
Maybe we're talking about the same thing, but basically, the way I see it is this:

1. Request for 2.5 comes in

2. Version 2.5 calls v2.6, takes the data, and transforms it into 2.5.

3. Since a 2.5 response shouldn't have a zipcode field, it's dropped from 2.6 before the 2.5 response is returned.

Re:APIs as infrastructure: future-proofing Stripe with versi... by lifeisstillgood on Wednesday August 16, 2017 @06:06AM (#15026270)
This kind of implies always have 2.5 running as front end code. I would rather have my latest code running (especially as it implies 2.4,2.3,,,1.3) and have that spin up the 2.5 munger code as needed. But yes I think it's more or less the same thing

Interestingly looking at stripe changelog https://stripe.com/docs/upgrades#api-changelog they still do breaking code changes every month or two so despite the effort and with a smallish api they break a lot of contracts.

The odd thing is that they keep a different api version for each customer, tagged at customers settings, so I suspect your approach (spin up api based on incoming version) might work better - but boy I think they may be in a lot of pain trying to maintain that backwards compatibility