01What is API Versioning Helper?
Picking a versioning scheme is easy to argue about and tedious to wire up. This helper takes the wiring part off your plate. You describe the API in a small JSON config and it writes out what that choice means in routes and code. The config needs a strategy (url-path, header, query-param or content-type), a basePath, a versions array and a resources array. You can add headerName or paramName to rename the header or query parameter. They default to X-API-Version and version. The last entry in versions counts as the latest, so keep the list oldest first. From that config you get four panels. Generated Routes lists GET, POST, GET /:id, PUT and DELETE for each resource. Depending on the strategy, the version sits in the path, sits in a header or query annotation, or appears as an Accept line such as application/vnd.example.v2+json. Swap example for your own vendor name. Middleware gives you Express code. For url-path that means one router per version, plus a 308 redirect that sends unversioned paths to the latest version. Paths that already carry a known version are left alone, so a typo under /v2 hits your 404 handler instead of looping. For header and query-param, a function reads the value, falls back to the latest version, and answers 400 with the supported list when it doesn't match. The header version also calls res.vary, so HTTP caches keep responses for different versions apart. Router Code is a Next.js App Router route.ts for the first resource. It reads the version from the [version] segment (awaiting params, which became a Promise in Next.js 15), the header, the query string or the Accept header. Then it switches to one handler per version. You write those handlers. Labels like 1.0 or 2.1-beta become valid names such as handle_v1_0. Migration Guide adds a checklist, a deprecation timeline with [DATE] placeholders and a client diff for each consecutive pair of versions. A quick example: header strategy, versions 1 and 2, resource orders. You get five routes tagged [X-API-Version: 1|2] and middleware that treats a missing header as version 2. Some honest limits. Content-type gets GET routes only, a placeholder comment for Express, and no client diff in the guide. The router file covers GET only. Nothing is deployed or sent anywhere, the whole thing runs in your browser.
Backend engineers and API leads who have picked a versioning scheme and want the routes, Express middleware and a Next.js handler drafted before writing real logic. The tool runs entirely in your browser, so your data never leaves your device.
02How to use API Versioning Helper
- Pick one of the examples, or type your own object into Configuration (JSON) with strategy, basePath, versions and resources.
- Add headerName for the header strategy or paramName for query-param if the defaults don't match your API.
- Fix any error shown in the red message box. Invalid JSON shows the parser message, and a bad strategy or empty versions list gets a plain explanation.
- Read the Generated Routes, Middleware, Router Code and Migration Guide panels, which update as you type.
- Use Copy on the panel you need, or Reset to clear the config.
03Worked examples
- Input:
{"strategy":"url-path","basePath":"/api/","versions":["v1","v2"],"resources":["users"]} - Result:
Generated Routes: GET /api/v1/users POST /api/v1/users GET /api/v1/users/:id PUT /api/v1/users/:id DELETE /api/v1/users/:id GET /api/v2/users ... (same five routes) Middleware (end): const VERSIONS = ["v1","v2"]; app.use("/api", (req, res, next) => { const first = req.path.split("/")[1]; if (VERSIONS.includes(first)) return next(); res.redirect(308, `/api/v2${req.originalUrl.slice(4)}`); }); - Trimmed. The trailing slash on basePath is dropped, and unversioned paths get a 308 to v2, the last version in the list.
- Input:
{"strategy":"header","basePath":"/api","versions":["1","2"],"resources":["orders"],"headerName":"X-API-Version"} - Result:
GET /api/orders [X-API-Version: 1|2] POST /api/orders [X-API-Version: 1|2] GET /api/orders/:id [X-API-Version: 1|2] ... function versionMiddleware(req, res, next) { const version = req.get("X-API-Version") || "2"; const supported = ["1","2"]; ... res.set("X-API-Version", version); res.vary("X-API-Version"); // caches must key on the version header next(); } - Trimmed. A missing header falls back to 2, unknown values get a 400 with the supported list.
- Input:
{"strategy":"query-param","basePath":"/api","versions":["1.0","2.0"],"resources":["items"],"paramName":"version"} - Result:
### Migrating from 1.0 → 2.0 #### Deprecation Timeline - 1.0 deprecated: [DATE] - 1.0 sunset: [DATE + 6 months] - Migration deadline: [DATE + 3 months] #### Client Updates Required ```diff - fetch(`${BASE_URL}?version=1.0`); + fetch(`${BASE_URL}?version=2.0`); ``` - Part of the Migration Guide panel. The dates stay as placeholders because the tool can't know your schedule.
- Input:
{"strategy":"content-type","basePath":"/api","versions":["v1","v2"],"resources":["users"]} - Result:
Generated Routes: GET /api/users [Accept: application/vnd.example.v1+json] GET /api/users [Accept: application/vnd.example.v2+json] Middleware: // Content-type versioning middleware // Implementation varies by framework - Media-type versioning lists GET routes only and gives no Express code.
- Input:
{"strategy":"header","basePath":"/api","versions":["2024-01","2.1-beta"],"resources":["orders"],"headerName":"Api-Version"} - Result:
// File: app/api/orders/route.ts ... const version = request.headers.get("Api-Version") ?? "2.1-beta"; ... switch (version) { case "2024-01": return handle_v2024_01(request); // write one handler per version case "2.1-beta": return handle_v2_1_beta(request); // write one handler per version } - Trimmed Router Code. Labels with dashes or dots become valid function names, and a leading digit gets a v prefix.
04Common use cases
- Putting URL-path and header versioning side by side in a design review before a public REST API ships
- Scaffolding Express middleware that rejects unknown X-API-Version values with a 400 and a list of supported versions
- Drafting the v1 to v2 migration checklist you send to client teams, then filling in the real dates
- Getting a starting route.ts for app/api/[version]/users in a Next.js 15 project without looking up the async params signature
- Checking what a date-style version label such as 2024-01 turns into in generated handler names
- Showing a junior developer why a header-versioned API needs a Vary header for caching
05Tips
- Order matters in versions. The tool treats the last item as the latest, so it becomes the redirect target and the fallback when a client sends no version.
- A trailing slash on basePath is stripped, so /api/ and /api produce the same output.
- Fill in the [DATE] placeholders and announce them to clients with the Deprecation (RFC 9745) and Sunset (RFC 8594) response headers.
- The query-param middleware compares req.query directly. A request like ?version=1&version=2 arrives as an array and gets a 400, which is usually what you want.
- If you pick content-type, plan to write the Express side yourself. The Next.js router code shows one regex for pulling the version out of Accept.
06Related concepts
REST API versioning, Content negotiation, Express middleware, Vary header, Deprecation and Sunset headers, Next.js route handlers.
Frequently Asked Questions
What is API Versioning Helper?
API Versioning Helper is a free, browser-based developer tool on AIDToolStack. Generate versioned API routes and guides It requires no installation or sign-up and works entirely in your browser.
Is API Versioning Helper free to use?
Yes. No sign-up, no fees and no usage cap.
Does API Versioning Helper store my data?
No. It runs in your browser; nothing is uploaded.