mcpField
A
api-versioning-strategy

api-versioning-strategy

github.com/secondskyDevelopment242405 installsUpdated 5w ago
Repository

About api-versioning-strategy

A skill for choosing API versioning methods and planning implementation and deprecation. It gives developers patterns for version adapters, compatibility decisions, and staged retirement.

Key features

  1. 01Compares URL, header, and query versioning
  2. 02Shows URL-path router setup
  3. 03Explains version adapter patterns
  4. 04Distinguishes safe and breaking changes
  5. 05Outlines deprecation timelines

Use cases

  1. 01Selecting a versioning method for a new API
  2. 02Adding a version while retaining older routes
  3. 03Planning client migration and endpoint retirement

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/secondsky/claude-skills --skill api-versioning-strategy

After installing, type/api-versioning-strategyin Claude Code to confirm it loaded.

Details

From the project README

API Versioning Strategy

Choose and implement API versioning approaches with proper deprecation timelines.

Versioning Methods

MethodExampleProsCons
URL Path/api/v1/usersClear, cache-friendlyURL clutter
HeaderAPI-Version: 1Clean URLsHidden, harder to test
Query?version=1Easy to useNot RESTful

URL Path Versioning (Recommended)

const v1Router = require('./routes/v1');
const v2Router = require('./routes/v2');

app.use('/api/v1', v1Router);
app.use('/api/v2', v2Router);

Version Adapter Pattern

// Transform between versions
const v1ToV2 = (v1Response) => ({
  data: {
    type: 'user',
    id: v1Response.user_id,
    attributes: {
      name: v1Response.user_name,
      email: v1Response.email
    }
  }
});

Deprecation Headers

app.use('/api/v1', (req, res, next) => {
  res.setHeader('Deprecation', 'true');
  res.setHeader('Sunset', 'Sat, 01 Jun 2025 00:00:00 GMT');
  res.setHeader('Link', '</api/v2>; rel="successor-version"');
  next();
});

Safe vs Breaking Changes

Safe Changes (no version bump):

  • Adding optional fields
  • Adding new endpoints
  • Adding optional parameters

Breaking Changes (requires new version):

  • Removing fields
  • Changing field types
  • Restructuring responses
  • Removing endpoints

Deprecation Timeline

PhaseDurationActions
Deprecated3 monthsAdd headers, docs
Sunset Announced3 monthsEmail users
Read-Only1 monthDisable writes
Shutdown-Return 410 Gone

Best Practices

  • Support N-1 versions minimum
  • Provide 6+ months migration window
  • Include migration guides with code examples
  • Monitor version usage to inform deprecation

Comments

Markdown supported