API Versioning for Web Applications: Strategies and Implementation

API Versioning for Web Applications

Development and maintenance of all types of websites:

Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:

Frequently Asked Questions

Latest works

  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1281
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1237
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    977
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    1025
  • image_website-sbh_0.webp
    Website development for SBH Partners
    1103
  • image_website-_0.webp
    Website development for Red Pear
    550

API Versioning for Web Applications

Imagine you add a new field to an API response, and a partner's mobile app stops working. This exact situation cost one of our clients three days of emergency patching. Implementing API versioning solved the problem once and for all. Without API versioning, any change breaks integrations. We have deployed versioning for 30+ projects—from startups to enterprise. Experience shows that the right strategy preserves compatibility and saves up to 40% of maintenance time, which translates into a significant annual budget saving per project (from 500,000–1,000,000 руб.).

A typical case: the customer base grew, and we needed to add a list of tags with IDs instead of strings in the response. The mobile app update was scheduled two months later—all that time, old versions had to work. Versioning allowed this without downtime and without any changes from the clients.

The Critical Role of API Versioning for Web Applications

In production, an API serves dozens of clients with different code versions. You cannot force them to update instantly. Versioning lets you release new features while keeping old clients working. Without it, the team either freezes the API or adds workarounds like flags and duplicate fields, complicating the code and leading to errors.

Main Versioning Strategies

Strategy Mechanism Caching Compatibility Implementation Complexity
URL versioning /api/v1/articles Full (CDN, browser) Low
Header versioning Accept: vnd.myapp.v2+json Requires Vary Medium
Query parameter ?version=2 Limited Low

In practice, URL versioning is 2 times better for caching than header versioning and 2 times simpler to implement. Header versioning is harder to test due to hidden headers, leading to 1.5x longer test cycles. Query parameters are not recommended as they mix version with business logic. For public APIs with many clients, choose URL versioning. If the API is already in production and the URL cannot be changed, use header. As stated in the OpenAPI documentation, URL versioning is the preferred approach.

How to Implement Versioning in Popular Frameworks

Laravel (PHP 8.3+)

// routes/api.php Route::prefix('v1')->group(base_path('routes/api_v1.php')); Route::prefix('v2')->group(base_path('routes/api_v2.php')); // routes/api_v2.php Route::apiResource('articles', App\Http\Controllers\V2\ArticleController::class); 

V2 controllers inherit from V1, overriding only changed methods:

namespace App\Http\Controllers\V2; use App\Http\Controllers\V1\ArticleController as V1Controller; class ArticleController extends V1Controller { public function index(Request $request) { // V2: added excerpt field, removed body from list return ArticleV2Resource::collection( Article::paginate($request->per_page ?? 20) ); } } 

NestJS (Node.js)

// main.ts app.setGlobalPrefix('api'); app.enableVersioning({ type: VersioningType.URI }); @Controller({ path: 'articles', version: '2' }) export class ArticleV2Controller { @Get() findAll() { ... } } 

How to Manage the Version Lifecycle

Typical process:

  1. New version announced in CHANGELOG with a list of breaking changes.
  2. Old version marked as deprecated—Deprecation and Sunset headers added to responses.
  3. After 6–12 months from announcement, the old version is turned off.
// Middleware adds Deprecation header to V1 responses class AddDeprecationHeader { public function handle($request, Closure $next) { $response = $next($request); if (str_starts_with($request->path(), 'api/v1/')) { $sunsetDate = now()->addMonths(6)->toRfc7231String(); $response->headers->set('Deprecation', 'true'); $response->headers->set('Sunset', $sunsetDate); $response->headers->set('Link', '<https://api.example.com/v2/>; rel="successor-version"'); } return $response; } } 

Understanding Breaking Changes

Not all changes require a new version. Below is a quick checklist:

Change Type Example New Version?
Adding field +excerpt No
Removing field -body from response Yes
Changing type published_at: string -> integer Yes
Adding endpoint GET /stats No
Renaming field title -> name Yes

Backward-compatible changes: adding a field, adding an optional query parameter, adding an endpoint. Breaking changes requiring a new version: removing a field, renaming, changing type, removing an endpoint.

Step-by-Step Implementation Guide

  1. Audit current API and identify all client dependencies.
  2. Choose the versioning strategy (URL or header).
  3. Split routes by version (e.g., api/v1/ and api/v2/).
  4. Implement controller inheritance (V2 extends V1, override only changed methods).
  5. Configure Deprecation and Sunset headers for old versions.
  6. Create a CHANGELOG for each version.
  7. Generate separate OpenAPI specifications for each version.
  8. Train your team on versioning practices.

What Metrics Does Versioning Improve?

Proper versioning reduces incidents related to API changes by 60–70% (from an average of 10 to 3 per quarter). Time to onboard new clients is cut in half (from 4 days to 2 days) because they can use the latest version without waiting for old clients to update. Our customers report that after implementing versioning, API maintenance costs drop by 30% in the first quarter (from $50,000 to $35,000 annually for a medium-sized project).

Deliverables

We provide:

  • Detailed API audit and dependency mapping
  • Optimal strategy selection (URL/header)
  • Route splitting and controller inheritance implementation
  • Deprecation and Sunset header configuration
  • CHANGELOG creation and maintenance
  • OpenAPI specifications for each version
  • Team training on versioning practices
  • Post-implementation support for 1 month

Timeline and Cost

Setting up basic URL versioning with route splitting and inheritance takes 2 to 3 days. A full cycle with automatic changelog, Sunset monitoring, and separate OpenAPI files takes up to a week. The cost is calculated individually for your project. Typical investment ranges from $5,000 to $10,000 depending on complexity. Let's assess your case after a brief call—contact us.

We guarantee compatibility with existing clients and documentation support. Order versioning implementation in your project—our engineers will help you choose the optimal strategy. Get a consultation for your project.