API Service
Design, build, and deploy a production-grade API with auth, rate limiting, and monitoring.
Phase Navigation
API Design
Define endpoints, data contracts, auth model, and API versioning strategy.
Why
API design is a contract that outlives your implementation. Once external developers depend on your endpoints, breaking changes cost them days of rework and cost you trust. Good design from the start means years of pain-free evolution.
When
Before writing any endpoint code. Typically 1-2 weeks for a well-scoped API. Design reviews with 2-3 engineers catch 80% of design flaws.
How
Example
Common Problems
- ⚠Inconsistent naming: camelCase in some endpoints, snake_case in others
- ⚠No versioning: first breaking change alienates all existing clients
- ⚠Verbs in URLs: /api/getUser instead of /api/users/:id — breaks REST conventions
- ⚠Leaking internal IDs: sequential IDs expose user count and enable enumeration attacks
Best Practices
- ✓Write the OpenAPI spec before coding — it's the contract and the docs
- ✓Use UUIDs for all public IDs — no sequential integers
- ✓Return consistent error shapes: { error: { code, message, details? } }
- ✓Version in the URL (/v1/) not in headers — it's visible and cacheable
Resources for this stage
Tools
Templates
Implementation
Build endpoints with validation, error handling, rate limiting, and tests.
Why
API implementation quality directly determines uptime, security, and developer experience. A single unvalidated input can cause a data breach. A missing rate limit can cause a DDoS. These are not theoretical risks — they are the most common causes of API incidents.
When
After design is approved. Typically 4-8 weeks for a 20-30 endpoint API. Build auth and rate limiting first — they're cross-cutting and hard to retrofit.
How
Example
Common Problems
- ⚠No input validation — trusting client data leads to SQL injection and data corruption
- ⚠Inconsistent error responses — clients can't programmatically handle errors
- ⚠No rate limiting — one client can exhaust database connections for everyone
- ⚠N+1 queries: listing endpoints that fetch related data per item instead of in bulk
Best Practices
- ✓Validate every input with a schema library (zod/joi) — never trust client data
- ✓Use consistent error envelope: { error: { code, message, details? } }
- ✓Add rate limiting on day 1 — it's a security feature, not a feature request
- ✓Use DataLoader or batch queries to eliminate N+1 patterns
Deployment & Monitoring
Deploy to production with zero-downtime, monitoring, alerts, and runbooks.
Why
API deployment is where code meets reality. Without proper monitoring, you're flying blind — the first sign of trouble is a customer complaint. Without zero-downtime deploys, every release risks dropping in-flight requests. Without runbooks, 3 AM incidents become multi-hour outages.
When
When implementation is tested and staged. Set up monitoring before the first production deploy — you need baseline metrics to detect anomalies.
How
Example
Common Problems
- ⚠No health check — load balancer can't know if the app is ready to receive traffic
- ⚠Deploying without migrations running — new code expects new schema, crashes on startup
- ⚠Alert fatigue: too many low-priority alerts -> engineers ignore PagerDuty
- ⚠No rollback plan: bad deploy at 3 PM, team scrambles to revert for 2 hours
Best Practices
- ✓Health check endpoint from day 1 — /health returns DB + cache + queue status
- ✓Run migrations before app starts, make them backward-compatible
- ✓Keep alerts actionable: each alert has a runbook link in the description
- ✓Practice rollbacks in staging — if you can't roll back in staging, you can't in prod
Resources for this stage
Tools
Templates
Full Developer Lifecycle
A 14-stage developer roadmap from idea to maintenance — visualize dependencies and track progress.
Next Step