DEV Community

RAGAVI
RAGAVI

Posted on

Guidelines for Deprecating Old API Versions

Image description

APIs (Application Programming Interface) are vital to helping companies grow their business. With business requirements and technology changing ever so frequently, there arises a need to have newer versions of the API, and there is also a need to deprecate the old ones. Deprecating an API needs to be well planned as you might have customers still using that version of the API. The paramount thing is to ensure there is a seamless transition for the customers.

Why Deprecate an API?

Deprecating an API version can be a difficult decision, abut it’s important to keep your API ecosystem healthy and up-to-date. The following are some reasons to deprecate an API:

  • Security vulnerabilities: Older API versions may have known security vulnerabilities that have been fixed in newer versions.
  • Technical debt: Older API versions may be built on outdated technologies or frameworks that are no longer supported, making maintenance difficult.
  • Performance: Older API versions may not be optimized for modern use cases, leading to poor performance and slower response times.
  • User experience: Deprecated API versions may contain confusing or redundant endpoints that can make it difficult for users to navigate.

What is API Deprecation?

API deprecation is the process of gracefully discontinuing an API. The process starts by first informing the customers that the API is no longer actively supported even though it will be operational and suggesting them to migrate to an alternate or latest version of the API. Sufficient time should be provided for the customers to migrate. Once the usage decreases, the API will be discontinued.

When to Deprecate an API?

Knowing when to deprecate an API is important to ensure a smooth transition for your users. Here are some factors to consider:

  • User adoption: If a large number of users are still actively using an older API version, it may not be wise to deprecate it immediately.
  • New features: If a new API version with additional features is released, it may be time to start phasing out the older version.
  • Technical debt: If the older API version is built on outdated technologies or frameworks, it may be time to start phasing it out to reduce technical debt.

How to Deprecate an API

Deprecating an API can be a complex process, but you can take these steps to make it easier. Here are some best practices to follow:

  • Notify users: Provide ample notice to users before deprecating an API version. This can be done through email, in-app notifications, or even a banner on the API documentation page.
  • Offer migration guides: Provide users with clear migration guides that explain how to transition to the new API version.
  • Provide support: Offer support to users who are having trouble migrating to the new API version.
  • Monitor usage: Keep an eye on usage patterns of the API version being deprecated to ensure that users are successfully transitioning to the new version.

API deprecation is one of the standard practices in software development. It can be a complex process depending on the number of users and the complexity of your API. To bring clarity to the process, we will split it into three stages:

  • Planning phase 
  • Execution phase 
  • Graceful deprecation 

Planning phase

An unplanned API deprecation can cause disruptions in the day-to-day business activities of customers, and in the worst case it can halt their business. The planning phase is the critical period of the API deprecation process which involves deciding on the deprecation deadline date, creating migration documents, and stabilising the new API version.

Deprecation deadline date

The deprecation deadline date or the sunset date is the date on which you decide that a particular version of the API will cease to function, and your customers will not be able to use it anymore. Deciding this date upfront will be beneficial for your customers as they will get sufficient time to migrate, and it will also help you to plan and streamline other activities related to the API deprecation process. The deadline date should be decided considering business needs and the complexity of migrating to the latest version of the API. The key takeaway here is that your customers should have ample time to migrate.

Migration documentation

Once you have decided on the deprecation deadline, it is time to ensure that you have detailed migration documentation before informing the customers. At a very high level, your migration documentation should cover things such as

  • Reason for deprecating the version of the API
  • Benefits of the latest version of the API
  • A clear list of the things which have changed in the new API
  • FAQs (Frequently Asked Questions) on how to migrate to the new version
  • Comprehensive documentation for the new API version

Stabilize the new API version

Before deprecating your old version, you need to ensure that your latest version is stable. There should not be any critical bugs in the latest version as that would give a bad experience for customers migrating to it. Test the latest version of the API thoroughly and iron out the bugs. Ideally, your new API version should be better than the old version in terms of features, security, and performance. This would be an encouraging factor for the customers to try out the new API version.

Execution phase

Now that we have the deprecation deadline date and the migration documentation ready, it is time to notify the customers of the API deprecation. By this time, all articles related to the migration should have been published and available for the customers to read. The main activities in this phase are to mark the old API documentation as deprecated, notify the customers and educate the support team on the migration process.

Mark as deprecated

All the existing documentation of the old API version should be marked as deprecated. Typically, most companies opt to display a banner on all the old documentation pages that link to the documentation of the new API version. If you are using specifications like OpenAPI or Open RPC etc., you can explicitly mark all the endpoints of the old version API as deprecated. By marking the old version as deprecated, you avoid new users from using the older version of your API.

Communication and reminders

You can send out formal emails, newsletters or write blogs or post in community forums etc., to reach out to your customers to inform them about the deprecation of the API and the alternative for it. Ensure that critical information like deprecation deadline date, migration plan etc., are included. You will want to periodically send reminders to the customers to ensure that the message reaches them.

Usage and support team

You should have a way to track the usage of the old version. Ideally, the usage of your old API should be decreasing. Depending on the business impact of your API, you might want to have a dedicated support team to reach out to the customers who are still using the old API and help them to migrate to the new API version. It is also good to have your support personnel trained in the migration process so they can address any migration related queries that they might get quickly.

Click here to read more

Top comments (1)

Collapse
 
rouilj profile image
John P. Rouillard

One other idea to consider is the sunset header rfc-editor.org/rfc/rfc8594. It's an informational RFC, but the Roundup REST API mentions it as part of future proofing the API.