URI Versioning — The /v1/ Approach
DodaTech
Updated 2026-06-28
1 min read
In this tutorial, you will learn about URI Versioning. We cover key concepts, practical examples, and best practices to help you master this topic.
URI versioning embeds the version in the URL path, making it visible, cacheable, and easy to route to different backend services.
Request Format
GET /api/v1/users
GET /api/v2/users
Implementation
const v1 = express.Router();
const v2 = express.Router();
v1.get("/users", (req, res) => {
res.json({ version: "1.0", data: usersV1 });
});
v2.get("/users", (req, res) => {
res.json({ version: "2.0", data: usersV2 });
});
app.use("/api/v1", v1);
app.use("/api/v2", v2);
Trade-offs
Pros: Simple, explicit, cache-friendly, easy to route, visible in logs. Cons: URL pollution, violates REST consistent URI principle, requires URL changes.
Common Mistakes
- Version in resource URL — /api/v1/users/v1 instead of /api/v1/users.
- No version in default route — Unversioned /api/users is ambiguous.
- Version after resource — /users/v1 instead of /v1/users.
Practice Questions
- What are the advantages of URI versioning?
- What are the disadvantages?
- Where should the version appear in the URL?
Challenge
Implement URI versioning for a task API with v1 and v2. v2 adds a priority field to tasks. Route requests to the correct version handler.
What's Next
In the next lesson, you will learn header versioning.
← Previous
Why Version Your API — Breaking vs Non-Breaking Changes
Next →
Header Versioning — Custom Headers for API Version
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro