Leonardo Arroyo
Leonardo Arroyo

Reputation: 593

What are the best practices to push API update information to running clients?

Let's say I have a Django REST API and a AngularJS client. Suppose I make a API change so I can implement a new feature to the client.
I push both the API and client changes to production at (almost) the same time. The new API version will be running, but there may still be several clients running old code on users browsers.

What is are the usual practices for pushing and reloading code on the browser?

Upvotes: 2

Views: 386

Answers (1)

Muli Yulzary
Muli Yulzary

Reputation: 2569

The best way to handle these cases is to roll out api changes by versions, much like Facebook and Google do.

Old clients will keep calling the deprecated api while the new ones will call the new api.

Note: when cleaning up older versions you must let your clients know that you are dropping support for the older clients!

Example:

//Old deprecated api
GET /api/v1/users
GET /api/v1/cars

//New api - if logic did not change just redirect to old api
GET /api/v2/users (unchanged) --> redirect to /api/v1/users
GET /api/v2/cars new implementation

That way you keep your code organized while still supporting old clients.

Upvotes: 1

Related Questions