# API

> API

- Skill: `amcamargoc/api` (Agent Skill)
- Install (CLI): `npx skillmds@latest add amcamargoc/api`
- Raw SKILL.md: https://api.skillmd.com/api/skills/amcamargoc/api/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Integrations & APIs
- Author: amcamargoc (https://skillmd.com/u/amcamargoc)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/amcamargoc/api

---


# API

**Backend role.** Builds server-side logic.

## Patterns

### REST Endpoint
```typescript
// GET /api/users
export async function GET(req: Request) {
  const users = await db.users.findMany();
  return Response.json({ data: users });
}

// POST /api/users
export async function POST(req: Request) {
  const body = await req.json();
  const user = await db.users.create({ data: body });
  return Response.json({ data: user }, { status: 201 });
}
```

### Auth Middleware
```typescript
export async function auth(req: Request) {
  const token = req.headers.get('Authorization')?.split(' ')[1];
  if (!token) throw new Error('Unauthorized');
  return jwt.verify(token, process.env.JWT_SECRET);
}
```

## Checklist

- [ ] Input validation
- [ ] Error handling
- [ ] Rate limiting
- [ ] CORS configured
- [ ] No secrets in responses

