Rest – Internal REST API versioning strategy

api-designreststrategyversioning

We are developing internal api's for integrating the server side logic (backend) with frontend (web, mobile etc). We have a java stack in our backend and front end is coded in react and react native. Since both of these are developed by our organization, as API providers we have complete control over the API consumers. Any change in the api could be synced up with the change in the api clients.

Are there any scenarios/use cases where we need to think of versioning internal/private api's? Do we need to think of a versioning strategy?

Best Answer

You should have a versioning strategy because that is key to independent evolvability, but it should be tied to Content-Type, not URLs or anything else.

Even in a closed-house setting, you should still strive to make all components of a system independently evolvable (isolated, modularised) — especially a distributed system like a client/server-based one. This both allows different teams to work on each at their own pace, and allows for different release cadences.

Why not in URLs?

URIs identify abstract things which cannot be versioned, like a user "Andy", or an invoice. A representation of that thing will have a particular serialisation, which can be versioned, application/andys-api-v1+json.

Your API (as with any website) is defined by three things. These are the only things that you need to document if your API is RESTful:

  • The root URL
  • The content type(s) of representations
  • the link relations between URIs

If a v1 client obtains a link to /users/andy from a previous request, it can forward that to a v2 client, which can then make a request to the same URL to get data about the same Thing, but in a language (content-type) it can speak, application/andys-api-v2+json.

The v1 and v2 clients might be different parts of the same program, in the midst of a development cycle. The key is that the clients both continue working throughout.

Related Topic