API versioning strategies for Google Antigravity IDE
# API Versioning Patterns for Google Antigravity
Master API versioning in Google Antigravity IDE. This guide covers URL versioning, header versioning, and deprecation strategies.
## URL Path Versioning
```typescript
// app/api/v1/users/route.ts
export async function GET() {
const users = await db.user.findMany({
select: { id: true, name: true, email: true }
});
return Response.json(users);
}
// app/api/v2/users/route.ts
export async function GET() {
const users = await db.user.findMany({
select: {
id: true,
name: true,
email: true,
profile: { select: { avatar: true, bio: true } }
}
});
return Response.json(users);
}
```
## Header-Based Versioning
```typescript
import { NextRequest, NextResponse } from "next/server";
export async function GET(request: NextRequest) {
const version = request.headers.get("API-Version") || "1";
switch (version) {
case "1":
return handleV1();
case "2":
return handleV2();
default:
return NextResponse.json(
{ error: "Unsupported API version" },
{ status: 400 }
);
}
}
async function handleV1() {
const users = await db.user.findMany();
return Response.json(users);
}
async function handleV2() {
const users = await db.user.findMany({ include: { profile: true } });
return Response.json(users);
}
```
## Deprecation Headers
```typescript
export async function GET(request: NextRequest) {
const response = await handleV1Request();
return new NextResponse(JSON.stringify(response), {
headers: {
"Deprecation": "true",
"Sunset": "Sat, 31 Dec 2025 23:59:59 GMT",
"Link": "</api/v2/users>; rel="successor-version""
}
});
}
```
## Best Practices
1. **URL versioning** - Most explicit and discoverable
2. **Sunset headers** - Communicate deprecation timeline
3. **Maintain backwards compatibility** - Within major versions
Google Antigravity IDE provides API versioning scaffolding.This API prompt is ideal for developers working on:
By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their api implementations.
Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.
This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.
You can modify the prompt by adding specific requirements, constraints, or preferences. For API projects, consider mentioning your framework version, coding style, and any specific libraries you're using.