Home · Developers · Guides · API Versioning

APIs

API Versioning

Version negotiation

The Nova Coder API supports versioning to enable evolution of the API without breaking existing clients.

Overview

API versioning allows the API to evolve over time while maintaining backward compatibility with existing clients. The system supports version specification via URL path or HTTP headers.

Versioning Strategy

Correction (2026-11): APIVersionMiddleware detects a version from the URL path (/api/vN/...), header, or query param and records it on request.state.api_version, but it does not rewrite the path and no /api/vN/* routes are registered — POST /api/v1/chat 404s. In practice, versioning is metadata-only: every real endpoint lives at the unversioned /api/* path and every supported version string resolves to the same handlers. Use header/query versioning (or nothing) and call /api/chat.

URL Path Detection

The middleware recognizes a version embedded in the URL path (/api/v1/..., /api/v2/...) for validation and response headers — but those paths are not routable; only v1 is supported and v2 is rejected with 400.

Header Versioning

Include the version in the X-API-Version header:

X-API-Version: v1

Default Version

If no version is specified, the system defaults to v1.

Supported Versions

  • v1: Current stable version
  • Future versions will be added as needed

Version Lifecycle

  1. Stable: Production-ready version
  2. Deprecated: Version marked for future removal
  3. Retired: Version no longer supported

Migration Guide

When a new version is released:

  1. Review the changelog for breaking changes
  2. Update your API calls to use the new version
  3. Test your integration with the new version
  4. Migrate before the old version is retired

Usage Examples

Using URL Path Versioning

import httpx

# The only supported version is the default — just call the unversioned path
response = httpx.post("http://localhost:8000/api/chat", json={
    "message": "Hello"
})

Using Header Versioning

import httpx

# Use header versioning
response = httpx.post("http://localhost:8000/api/chat", 
    json={"message": "Hello"},
    headers={"X-API-Version": "v1"}
)

Implementation

The API versioning is implemented via the APIVersionMiddleware in novacoder/api/versioning.py:

from novacoder.api.versioning import APIVersionMiddleware

app.add_middleware(
    APIVersionMiddleware,
    default_version="v1",
    supported_versions=["v1"]
)

Source: wiki/api-versioning.md · rendered 2026-11-10