Implement API versioning strategies including URL versioning, header versioning, backward compatibility, deprecation strategies, and migration guides. Use when dealing with API versions, deprecating endpoints, or managing breaking changes.
Comprehensive guide to API versioning approaches, deprecation strategies, backward compatibility techniques, and migration planning for REST APIs, GraphQL, and gRPC services.
Minimal working example:
// express-router.ts
import express from "express";
const app = express();
// Version 1
app.get("/api/v1/users", (req, res) => {
res.json({
users: [{ id: 1, name: "John Doe" }],
});
});
// Version 2 - Added email field
app.get("/api/v2/users", (req, res) => {
res.json({
users: [{ id: 1, name: "John Doe", email: "john@example.com" }],
});
});
// Shared logic with version-specific transformations
app.get("/api/:version/users/:id", async (req, res) => {
const user = await userService.findById(req.params.id);
if (req.params.version === "v1") {
res.json({ id: user.id, name: user.name });
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents | |---|---| | Versioning Approaches | Versioning Approaches | | Backward Compatibility Patterns | Backward Compatibility Patterns | | Deprecation Strategy | Deprecation Strategy | | Migration Guide Example | Migration Guide Example | | Response Structure | Response Structure | | Date Format | Date Format, Error Format | | JavaScript/TypeScript | JavaScript/TypeScript, Python | | GraphQL Versioning | GraphQL Versioning | | gRPC Versioning | gRPC Versioning | | Version Detection & Routing | Version Detection & Routing | | Testing Multiple Versions | Testing Multiple Versions | | Pattern 1: Version-Agnostic Core | Pattern 1: Version-Agnostic Core, Pattern 2: Feature Flags for Gradual Rollout, Pattern 3: API Version Metrics |
Copy a source-pinned command for your client. You run it yourself.
Destination: .claude/skills/api-versioning-strategy · pinned to the source commit
git clone https://github.com/aj-geddes/useful-ai-prompts.git
cd useful-ai-prompts
git checkout 3f5182cfd739fc113f4af5244a1cf342ad7f7911
mkdir -p ".claude/skills/api-versioning-strategy"
cp -r "skills/api-versioning-strategy" ".claude/skills/api-versioning-strategy"Review the source before running. This copies files into your project; it is not a one-click install and does not verify runtime safety.
Scanner static-checks@0.1.0 · commit 3f5182cfd739. Static checks cannot prove runtime safety – review the source and the exact diff before installing. How checks work.
No static rules matched. This is not a safety guarantee.