API Fundamentals Course
API Fundamentals
/
Beginner

URL Versioning

Definition

The most common and explicit strategy for API versioning, where the version number is embedded directly into the URL path.

Explain Like I'm New

You put `/v1/` in the URL. When you need to make breaking changes, you create a new set of endpoints starting with `/v2/`. Both URLs run on the server at the same time.

Real World Example

Twitter's API. `api.twitter.com/1.1/tweets` uses their old format. `api.twitter.com/2/tweets` uses their completely redesigned modern format.

Common Use Cases

  • •Public APIs
  • •Simplicity and routing ease

Interactive Example

Loading...
Console output will appear here...

Interview Questions

basic

  • Give an example of a URL-versioned endpoint.

intermediate

  • What is the main architectural criticism of URL Versioning among REST purists?

Flash Cards

Question

Example?

Click to reveal answer
Answer

`https://api.mycompany.com/v1/users`

Question

Criticism?

Click to reveal answer
Answer

REST purists argue that a URL should point to a specific *Resource* (the user). A version is not a resource; it is a representation of the data. Therefore, versioning should theoretically happen in the Headers, not the URL.