QA
Beginner LevelREST APIs & Web Services

What are API Versioning strategies (URI path vs Query parameter vs Custom Header)?

❓ Interview Prompt: Compare URI path versioning (`/v1/`), query parameters (`?v=1`), custom headers (`X-API-Version`), and Accept media type headers.

API Versioning allows introducing breaking changes without breaking existing client integrations:

1
URI Path Versioning (Most Popular): '/api/v1/users' vs '/api/v2/users'.
•
Pros: Highly visible, easily cached by CDNs and proxies.
2
Query Parameter Versioning: '/api/users?version=2'.
3
Custom HTTP Header: 'X-API-Version: 2'.
4
Accept Header (Vendor Media Type / RESTful): 'Accept: application/vnd.company.v2+json'.

Code Implementation Example

typescript
import express from 'express';
const app = express();

// Route level versioning
app.use('/api/v1/users', v1UserRouter);
app.use('/api/v2/users', v2UserRouter);
💡Routing versioned API endpoints using Express route handlers.
🎯 Interview Key Takeaway

URI path versioning (/v1/resource) is the most widely adopted pattern due to simplicity and CDN caching support.

#Versioning#API Design#Architecture#Beginner
Back to all REST APIs & Web Services Questions→

More REST APIs & Web Services Interview Questions

Beginner LevelREST APIs & Web Services

What is HTTP Method Idempotency and how do you implement Idempotency Keys for REST APIs?

Beginner LevelREST APIs & Web Services

What are standard HTTP Status Codes (200, 201, 204, 400, 401, 403, 404, 409, 429, 500, 503)?

Beginner LevelREST APIs & Web Services

What are HTTP Verbs (GET, POST, PUT, PATCH, DELETE) and when to use PUT vs PATCH?