9 ms·
How Shopify Manages API Versioning and Breaking Changes
- keithwhor 7y agoHi everyone. As the founder of an API company, this article has me wondering about the semantics of versioning — so I thought I’d ask the community a question. I hope the Shopify API team doesn’t mind! When you all think about API versioning, what makes the most sense to you — a semver approach (major.minor.patch) a la NPM, or a date-based approach (2020-01-07) a la AWS? Or is some combination of the two desirable? At Standard Library [0] we both allow people to publish APIs but also publish API proxies on behalf of partners (Stripe, Slack + others) using a semver approach. It’s not perfect but theoretically enforceable (schema parameter additions can be forced to require a minor update, schema parameter removals can be forced to require a major update). We’ve just stuck to this semver approach based on intuition and haven’t had negative feedback about it, but I do like the idea of time-based versioning. Would love thoughts! If you want to play around you can build your own APIs using https://code.stdlib.com/ https://code.stdlib.com/, which uses the FunctionScript specification [1] to enforce HTTP request schemas. [0] https://stdlib.com/ https://stdlib.com/ [1] https://github.com/FunctionScript/FunctionScript https://github.com/FunctionScript/FunctionScript
- Navarr 7y agoI do not know any advantage of date-based versioning, other than someone knowing how new it is. Semver is important for knowing whether or not to evaluate for breakages. You can theoretically combine both of these by making the date the patch version or supplying it as a version metadata
- Znafon 7y ago> I do not know any advantage of date-based versioning It can be very useful for continuous improvement and handling forward compatibility. Here's how Stripe do it:https://stripe.com/en-fr/blog/api-versioning https://stripe.com/en-fr/blog/api-versioning, we found that very convenient.
- keithwhor 7y agoI think it’s the implied stability, especially for long-standing APIs. S3’s API is 2006-03-01 — meaning there haven’t been breaking changes in over 13 years. This creates a psychological contract with developers that nothing’s changing anytime soon. The trade off is that AWS has some godawful APIs (DynamoDB has the least intuitive API I have ever worked with). But they’re stable. If you go with a date-based approach and create a process + contract whereby you guarantee API stability and / or deprecation date, the developer always knows exactly how much time they have before an upgrade.
- thdrdt 7y agoBoth don't say much without good changelog. But with semver you can say: ok, I want every new version up to a new minor version (all fixes). While with a date based version you don't know how 'breaking' the changes will be.
- keithwhor 7y agoHow often do you feel like you find / consume changelogs when you’re looking at APIs? I feel like they’re either non-existent or non-obvious for most SaaS companies. Do you feel like you’d trust a company’s API more if you could peruse the API changelog more easily?
- thdrdt 7y agoIt's not about trusting a company. It's about wanting to know what will break if you start using a newer version of an API. And sometimes you also discover new features that can be really useful.
- keithwhor 7y agoThat’s fair! From my perspective that’s something that’s building trust with the SaaS provider. We’ve all heard, “ugh! This API is so shitty!” before — I’m fascinated by what tools and products can be built to prevent developers from feeling these pains. Thanks for the feedback. Can definitely see that changelogs are really underinvested in across the industry, and it’s useful to have people mention how valuable they are.
- k__ 7y agoI never understood why we settled on semver. If I have a bug, it's a breaking change. If I fix this bug, it's also a breaking change.
- tclancy 7y agoYour presumption of a collective "we" is at the root of the problem: versioning is one of those things in development where the same word can mean very different things to different people (see also: agile, automated testing). Prior to semantic versioning, there was an approach that looked like an agreed-upon standard to consumers of software packages/ libraries/ APIs but was not. On one extreme you had certain developers (who I am sympathetic to because it's my personality) who were loath to ever label something 1.0 because it implies Doneness and a freedom from bugs that can never be so. On the other side you had people at chop shops who would bump the major version of some boxed product every time they fixed two bugs. Even if you as a good developer did the research to discover that 0.7.6 of Package A was solid and 5 years older than Package B 7.6, there was a good chance someone above you would declare 7.6 > 0.7.6 and that it was paid-for software so "We can get support from them" and force you to work with a shittier product. So "we" developers do what we almost always do: we cast about for a better solution and landed on one that made the meaning of version numbers opaque to anyone outside the guild of mages writing code. In short, semantic versioning may suck hard, but it sucks less.
- eapache 7y agoMy impression is that semver makes far more sense for published libraries (DLLs or ruby gems or npm packages etc) while date-based makes far more sense for SaaS APIs. The constraints and usage patterns are fairly different between the two.
- keithwhor 7y agoWhat specifically about SaaS API constraints do you think makes a date-based approach more appealing than semver? My high-level feeling is that it’s just way more difficult to ship a SaaS API than a Ruby Gem, so adding semver to that is just another layer of API management everybody has to agree on. Do you agree with this assessment?
- eapache 7y agoFor most published libraries every old version is always available and upgrading is never mandatory. For SaaS APIs the constraints of the business means that very few businesses (Stripe being the notable exception) want to support more than a handful of versions at a time, which results in versions regularly reaching end-of-life and completely disappearing. In this world, upgrading to newer APIs is mandatory and fairly frequent. The result is that API version handles need to prioritize different information. Libraries need a format that makes it easy to ballpark the size of changes between arbitrary not-strictly-sequential versions. SaaS APIs need a form that makes it easy to infer support windows and end-of-life status.
- keithwhor 7y agoGood points. Do you think a combination of the two is possible, and how do you think that might work? year.month.minor.patch?
- ahnick 7y ago> "SaaS APIs need a form that makes it easy to infer support windows and end-of-life status." You can infer that from the Release Date though. (e.g. Version 3.4.2 Released on 2019-12-17) To me the power of Semver is that it conveys complex relations between version iterations. For example: - 3.4.1 -> 3.4.2 is just fixing bugs in existing functionality - 3.4.2 -> 3.5.0 is an upgrade containing non-breaking changes - 3.5.0 -> 4.0.0 is an upgrade containing breaking changes As a developer, Semver + release date seems to convey everything date based versioning does plus I get the advantage of understanding at glance the importance and risk profile of each release. Note, this system does not reduce my obligation to run my own tests to verify that the version has in fact lived up to its intention (i.e. a minor version bump did not introduce a breaking change). Even though my obligation is not reduced, it does act as a filter to help prioritize development time for evaluation of performing upgrades.
- m12k 7y agoI prefer semver, but it's still not exactly what I want. What I'm looking for is the answer to 'how painful/risky is upgrading likely to be?'. I expect an x.x.1 release to be zero/low risk - small fixes only within current api and contract. I expect a 2.x.x release to come with major risk of breakage (and I'll almost always want to wait for 2.0.2-2.0.3 before actually upgrading - and I expect a 1.x.x -> 2.x.x release to have a risk of bigger changes compared to a 5.x.x -> 6.x.x since the latter is expected to have the fundamentals ironed out by now). But there doesn't seem to be much consensus on whether an x.1.x release can have breaking changes or not - or maybe they don't come with as strict a definition of a breaking change as Shopify is using - so I'm left with treating them the same as 2.x.x (though usually I don't wait for x.x.1 in this case).
- keithwhor 7y agoWould a tool that easily shows you documentation / schema changes between API versions be useful to you, or create more trust with a SaaS provider if they offered it?
- gen220 7y agoI’m pretty sure the semver definition for a x.2.x change is that you’re adding surface area to your interface, in a way that doesn’t overlap with existing surface area, i.e. bytes sent over the wire for x.1.x will result in the same response bytes for x.2.x, all else being equal. Note that the phrase non-overlapping is where all the complexity is hidden; it’s actually tricky to guarantee that an addition hasn’t changed any existing queries. For example, adding an enum value will mess up clients who query with max(enum_value). Technically, they’re not sending the same bytes, so the change is non-overlapping, but the client might disagree :)
- Waterluvian 7y agoI don't think there's one right answer, but my opinion is: - Treat APIs as immutable. - Any mutation results in a wholly new API version, not a patch or minor update. - The developer will learn what changed, and how much changed by reading the patchnotes, not looking at which semver numbers changed. This is probably a healthy practice to encourage. - Don't change APIs so much. The interface should be very carefully designed and tested and shipped like an NES cartridge: consider it impossible to fix once its shipped. Therefore just start with `1` and increment each time. The reason I don't like semver is that it's a developer convenience that leads to sloppy practices. You built your product against a specific API. If the API changes, you need to re-run your entire API evaluation, testing, blessing workflow. If the delta is tiny (what would have been a patch change) then yay, your task is likely going to be very simple. But you shouldn't see a bump version update and decide you can cut corners.
- keithwhor 7y agoI don’t disagree with your assessment on semver as it currently exists for, say, NPM packages. I do think that with web APIs specifically, the surface area is a lot smaller — the HTTP interface is literally all you touch — so semver, in its purest form, is actually completely enforceable as long as you understand the API schema. Our team has talked a lot about either hard-enforcing or automatically applying semver where applicable. My question to you is — does this sound reasonable, and if you knew a semver contract was actually bound to implementation (i.e. guaranteed and not implied), would you trust it more?
- setr 7y agoTbh, it doesn't matter. But the semantics should be such that it doesn't matter -- the user of the API shouldn't care whether it's implementation bounded or not. But Everytime you break that abstraction, trust in the abstraction is necessarily reduced. Bounding to implementation is just the easiest way out -- if your policies, tests and protocols consistently fail to uphold that abstraction, then the you can fallback to this very simple (presumably innefficient) strategy to do so. But I, as a dev, just want a stable API, and I don't care how it's done.
- seelmobile 7y ago(Disclosure: I work at Google on public APIs, opinions are my own) Google's proposed a "stability" semantic as a third option[0]. TL;DR no breaking changes in the Stable channel but you can add backwards-compatible[1] features in-place. A permanent Beta channel that's a superset of Stable lets users choose how change-tolerant they are. This lets API producers launch features earlier, knowing they will only impact risk tolerant users if breaking changes are needed. Theoretically this reduces the need for breaking changes in Stable, which require a new Major version. [0] https://aip.dev/181 https://aip.dev/181 [1] https://aip.dev/180 https://aip.dev/180
- keithwhor 7y agoDo you think it’s possible to achieve the same sort of system by just using semver + release candidates? For example, 5.x.x is currently stable, so you release 6.0.0-rc1 (2, 3, ...)?
- posedge 7y agoHonestly, I don't see what a non-semantic scheme brings to the table. In SemVer, you can (theoretically) infer compatibility from the version number. A date tells you nothing.
- bmn__ 7y ago> When you all think about API versioning, what makes the most sense to you — a semver approach (major.minor.patch) a la NPM, or a date-based approach (2020-01-07) a la AWS? Or is some combination of the two desirable? We're talking about HTTP APIs, right? Then neither. These are solutions with bad trade-offs for the problem at hand. Version the link relations. This follows the principles that make the Web successful (a.k.a. REST). If that seems weird to you¹, consider the following: You have a personal homepage type Web site. When you change or add or remove a document, do your users need to upgrade their user agent to keep using the site? Why not? ---- ¹ Numerous developers are so enamoured with putting a version number into document URIs that they cannot fathom not doing it. This is another mutilation of the mind à la Dijkstra.
- NicoJuicy 7y agoV1 V2 V3-dev/v3-test/v3-rc - all related to how many changes you expect V3
- solatic 7y agoWhat's the point of a patch release for an API? If you publish API version 1.0.0, and then internally you fix something and publish 1.0.1 (remember: a patch doesn't change the interface at all), should you continue to serve both the 1.0.0 and 1.0.1 APIs? How are they different from the consumer's perspective? What if your reason to release 1.0.1 is to fix a security issue - in what world is it ethical to continue to serve 1.0.0? If you can discontinue serving 1.0.0 at any time (because of a security patch released with 1.0.1), then you can't offer any long-term durability guarantees for early patch versions, and so indeed, offering older patch versions (when newer patches didn't fix security issues) is more likely to break your consumers when you're forced to discontinue older patch versions for security reasons, than if you refused to serve patch-level variants in the first place. Because you, as upstream, have no control over whether the pure addition of fields will break downstream (since downstream may or may not be strict about what they accept), you should only offer semantically versioned minor releases if you're willing to guarantee durability for earlier minor versions, and can maintain multiple minor versions of your API in parallel. If not, then be explicit about the potential of your changes to break downstream - use timestamps and document sunset dates.
- Judson 7y agoIt's interesting to compare and contrast this method of API management with Stripe. As far as I understand, the Stripe api would continue to work indefinitely so long as you lock your api version, whereas Shopify would eventually break the app as they essentially backport breaking changes to older api versions. Initially, I thought Stripe's method was superior, and would provide the best API experience, but realized that Stripe and Shopify have different incentives w/r/t their api. For Stripe, breaking a functioning site harms revenue, and generally the developer is the Stripe customer. For Shopify, their customer is the store owner, and for the most part, the store will continue to function because that is mostly controlled by shopify. The developer api is for added functionality, and it is in the interest of Shopify and the merchant that those apps continue to be updated and utilizing the latest features. So, two different ways of managing breaking changes, but both are ultimately centered around providing the best customer experience.
- gingerlime 7y agoFunny that you mention Stripe, because it was definitely the canonical backwards compatibility API for me. ... Until just recently in mid Nov they changed some behavior that caused us to double/triple/quadruple charge customers unintentionally in some not-so-uncommon edge cases... I’m still trying to square this one with their support, so details are a bit thin. But definitely a big surprise for me to see this happening when previously I never imagined something like this can happen given the API versioning stability.
- Judson 7y agoYou know, you just jogged my memory here. We did have an issue with Stripe changing the order / timing of payment_failed webhooks, which caused them to be sent before the next payment attempt was known. We used the payment failed hook to send an email to our customers and let them know when we'd be retrying the charge, which was no longer possible because the next_payment_attempt field was null. Before the change, a next_payment_attempt=null meant the charge would not be retried. I reported the issue and the webhook changes were rolled back a month later. Really threw a wrench into our flow. I will say that generally speaking, Stripe is the canonical backwards compatibility API in my mind. With a few edge cases.
- MentallyRetired 7y agoShopify made a change to their API that was easily measurable on who it would affect, but didn't email us. Refused to grant us a temporary exemption (they would do it for $2000/m they said). The end result? They've sunk my business. I've replaced shopify now by writing my own but it's too late. My customers have all gone to my competitors and we're looking at pivoting.
- Waterluvian 7y agoI would love to read more about this case study on how an API change by a business service sinks a business.
- thsowers 7y ago> Shopify made a change to their API that was easily measurable on who it would affect What was the change?
- joegahona 7y ago> The end result? They've sunk my business. What was the business?
- mmmannn 7y agoWhat was the change? AFAIK Shopify would never give a temporary exemption for money, that's very much against their philosophy as a SaaS. Either you provide accurate details or this is just FUD.
- MentallyRetired 7y agoIt was a limitation on the number of variants. They had no limits prior to this API update I'm talking about. My business allowed people to create merch and we'd add it to a collection on our storefront. Developer support told us sometimes they grant temporary exemptions. They did not. They told us we could upgrade to shopify plus which has no such limitations, but being a bootstrapped company we couldn't swing the $2k per month. Edit: Just to be clear, it was always on our roadmap to migrate away from Shopify's platform, but they accelerated our timeline and we had to limit the amount of merch our customers could add which obviously led to upset customers. We're still operating, albeit close to insolvent, and have since launched our new platform. But our reputation has been irreversibly damaged.
- leome 7y agoVery nice story, this is why I decided to use Shopify API as less as possible, so I won't need to care about the version.
- circular_logic 7y agoGlad to see that Shopify has better API versioning on their mind. When I used there API a few years ago, it was one of the worst APIs to depend on. To the point, we had to architect our system to alert us for unannounced breaking API changes so we could fix and replay the JSON back. - Moving JSON fields in and out of nestings didn't seem to be counted as a breaking change. - Changes were rarely announced, and there was never a changelog as to what had changed (they look to have started one starting 2018 [1]) - When we contacted support about a brake, they would often be surprised. - Often the only sign there would be a change would be that new fields would start to show up before a larger change. All this would happen every few months. Reading this article I can start to see the reasons why this was happening. [1] https://developers.shopify.com/changelog?filter=all https://developers.shopify.com/changelog?filter=all
- nozzlegear 7y agoI maintain a Shopify API package for .NET [0] and this has largely been my experience as well. Their attitude toward breaking API changes has caused me a good deal of frustration in the past. To make matters worse, their docs weren't (and still aren't, in my opinion) that great; my biggest complaint being they typically don't document when values can be null or even have a different type (e.g. property X could be a string or a decimal, but you'll never know looking at their docs). This has led me to taking the drastic step of making _every_ property nullable. It's gross and feels bad to use, but at least it prevents JSON parse operations from crashing applications when a value is unexpectedly null. [0]: https://github.com/nozzlegear/shopifysharp https://github.com/nozzlegear/shopifysharp
- hn_throwaway_99 7y agoTo be honest, when I read about these types of difficulties in managing changes in an API over time, I really wonder why more companies don't go over whole hog into GraphQL. GraphQL won't solve all your problems (sometimes changes are breaking because business needs require it), but GraphQL provides a better scheme for API evolution than any other API toolkit I've used: 1. You can just keep adding new methods and fields as needed, but since each client asks only for the fields specific to what they want, you don't get big bloated response objects. 2. Lots of times your breaking changes only differ slightly from previous versions, and the way GraphQL resolvers are written makes it really easy to refactor things into one base method that both the old and new versions can share. 3. Proper use of the @deprecated schema directive means your doc is 'clean' by always showing the latest version that new users should adopt, but the doc is still there for users on older versions. 4. It's really easy to add logging and tracing in your resolvers to see how often fields are being accessed and who is using them. At some point you may decide to break backwards compatibility by deleting old fields, but you'll know exactly who you are breaking.
- ch33zer 7y agoHow do they handle security fixes in old releases? If releasing a security patch requires backporting it to 5 different active releases then I'm unconvinced that this is a useful strategy.
- auv5 7y agoGreat question! As mentioned in the article, when making a change you would typically add an `ApiChange.in_effect?` check to see if your new functionality should execute. When we implement security fixes, we do not include this check and the fix retroactively applies to all API versions.
- etxm 7y agoAside, the article mentions frozen_record and it makes me wish that DataMapper had been a more successful project. I really enjoyed working with it.
- lol666 7y agoshopify is slow it doesnt matter how they manage their api...
- pbreit 7y agoJust don't make breaking changes. It's really not that hard.
- lol666 7y agoi know, i know, be constructive... but hey, shopify with +10k products is so slow they can version whatever they want...
- theturtletalks 7y agoAt that point, I would use something like Gatsby which would build static pages for each of your product pages. You could host that on S3 with a CDN for cheap. You could downgrade the Shopify plan to $9/month since you're not going to be using their storefront.
- lol666 7y agothank you, but this doesnt solve the speed issues in my case. i could use sylius or any other ecom that i could host myself and use custom speedup on code instead of just on cdn:) shop i mean is in uk and has only uk customers, no need for cdn as customers arent spread globally or even on the continent.. as for static wouldnt that work for every solution? in that case theres no need for shopify at all... but as you say i could even keep static code generated and served from redis instead of s/hdd, that would be even faster
- theturtletalks 7y agoThe main power of Shopify is the dashboard and the APIs. By having a custom storefront, Shopify just provides the APIs and a nice dashboard for non-programmers to use. You can also ditch Shopify later on since the storefront just builds off their API. Just my 2 cents. For $9/month, hosting something like Magento or even Woocommerce would be difficult.
- uyuioi 7y agoThe Shopify developer experience is terrible. No fluffy blog can change that fact. Shopify says the main product is the store owner. But the developers pick up all of the slack of Shopify. Recurring payments. App. Store backups. App. Theme backups. App. Order editing. Came late 2019. Checkout. So locked down. Where’s the API?! Slate tooling. Abandoned. Starter themes. Abandoned. Storefront SDK. Terrible documentation. More than 1 variant image? App. Metafields. App. Wholesale. App. Mailchimp. Removed. People talk about google abandoning products. Shopify abandons nearly all developer tooling and is so locked down that it’s a constant “app for that” for the basics. The interesting thing is theres been more than a few store owners I know that use Shopify. They’ve asked how to move off of Shopify. I guess fulfilment is more important though. Right?!
- theturtletalks 7y agoShopify's business plan is offer minimum functionality for a low monthly fee and then users use the marketplace to add additional functionality which Shopify takes a 20% cut. I'm actually working on an open-source fulfillment and operations app for Shopify: https://github.com/openshiporg/openship https://github.com/openshiporg/openship I use it to build small apps that interact with the API directly instead of paying and relying on any apps.
- uyuioi 7y agoBut Shopify hold the transaction fee and charge 2% on top. So really in the end. Shopify is not that much cheaper. Considering bigcommerce doesnt charge this. I am bullish on the long term of bigcommerce. Or anything that goes after the small medium business. I don’t think Shopify could sustain a real entrance by Adobe with Magento, or a product in the same space from someone like Microsoft. As these companies know developer tooling and in the end. Shopify needs developers. Developers don’t need Shopify.
- theturtletalks 7y agoYes but their are ways to circumvent this. You could just use Shopify as a headless CMS for $9/month. Use their storefront API and a static site builder like Gatsby as your storefront. Then you can integrate your own payments and create the order on the backend. You could even use the new Stripe Checkout page.
- petetnt 7y agoI want to love Shopify but Shopify doesn't want to love developers. For example when their multi-location offering [0] _in beta_ they also announced that the Inventory API is going to breakingly change in 2 months and _none_ of their own SDKs supported locations at that point. This has happened with Shopify time and time again. Shopify doesn't manage API versioning or breaking changes: it just forces developers to update or endure with their broken applications and interfaces. Sure, it's Shopify's choice. But considering how long their own changes take (for example multi-language is still in some sort of beta and it's been up and coming for like 5 years?) the API cycles are just brutal. And the saddest thing is that Shopify is still the best managed e-commerce platform for most usecases. [0]: https://help.shopify.com/en/api/reference/inventory https://help.shopify.com/en/api/reference/inventory
- james_s_tayler 7y agoWhere I work, we have found 3rd Party SDKs to be an anti-pattern for this and other reasons.