API Network Background
radio_button_unchecked Best Practices 2025

How should API Versioning be handled?

There is no single "correct" answer, but there are proven strategies. Whether you choose URI pathing for simplicity or Request Headers for purity, consistency is key.

check_circle The Short Answer

Most public web APIs (like Twitter, Google, Microsoft) use URI Versioning (e.g., /v1/users) because it is the easiest for developers to explore, debug, and cache.

However, purist REST architectures often prefer Header Versioning (e.g., X-API-Version: 1) to keep resource URLs clean. Stripe is the gold standard, using date-based header versioning with a robust backend compatibility engine.

Choose Your Strategy

Explore the four common implementation patterns. Click the tabs to see how the code and trade-offs change.

Request Preview
HTTP Request
GET /v1/users/123 HTTP/1.1
Host: api.example.com
Accept: application/json
Response (JSON) 200 OK
{
  "id": "usr_123",
  "name": "Alice Developer"
}

URI Path Versioning

Most CommonBrowser Friendly

thumb_up The Good

  • Easiest for developers to understand.
  • Explorable via browser address bar.
  • Easy to cache (URL is the key).

thumb_down The Bad

  • Technically violates REST (URL should define *what*, not *which version*).
  • Breaking changes require new URL structure.

Who uses this?

GoogleTwitterMicrosoft
extension
INTERACTIVE QUIZ

Breaking or Non-Breaking?

Test your knowledge. Does this API change require a new version?

Scenario 1 of 5

You add a new optional query parameter filter_by_role to the GET /users endpoint.

Real-World Case Studies

Rolling Versions
Stripe

Date-Based Header Versioning

Stripe-Version: 2024-09-30

Stripe is famous for its rolling versions. Every breaking change gets a new date. When a request comes in, their internal middleware "downgrades" the response object through a chain of transformers until it matches the date requested by the user.

star Best-in-class Developer Experience
GitHub Server
GitHub

Hybrid Header Versioning

X-GitHub-Api-Version: 2022-11-28
Historically used `Accept: application/vnd.github+json`

GitHub moved from pure media-type versioning to a dedicated header X-GitHub-Api-Version to make it easier for developers. They maintain strict semantic rules and provide long deprecation windows (24 months).

verified Industry Standard