API Design for Backend Services
A compact mental model for designing reliable, boring, useful APIs.
- Status
- evergreen
- Visibility
- public
- Category
- Backend
- Difficulty
- intermediate
- Published
- Jun 28, 2026
- Updated
- Jun 28, 2026
Design Priority
An API is a contract. Good API design makes correct client behavior obvious and incorrect behavior harder to ship.
Resource Shape
- Use nouns for resources and verbs for commands only when a resource model is awkward.
- Keep identifiers stable and opaque.
- Return consistent envelope or bare-resource shapes; do not mix casually.
- Make pagination, filtering, sorting, and field selection explicit.
Error Shape
Every error should answer:
- What happened?
- Can the client retry?
- Which field or dependency caused it?
- How can the client correlate this with server logs?
{
"error": {
"code": "rate_limited",
"message": "Too many requests.",
"retry_after_seconds": 30,
"request_id": "req_123"
}
}
Idempotency
Use idempotency keys for create operations that may be retried by clients, queues, or workflow engines. This matters for payments, media generation, job creation, and external API orchestration.
Versioning
Prefer additive changes. When breaking changes are unavoidable, version the external contract and document the migration path.
AI API Twist
For LLM and media APIs, expose operational state:
- queued
- running
- succeeded
- failed
- canceled
Do not force clients to hold open a request while expensive work runs.
Source Links
Related Notes
API Design Checklist
A practical checklist for reliable HTTP API design.
FastAPI Production Checklist
A compact checklist for taking a FastAPI service from useful prototype to production-ready backend.
Backend and AI Infrastructure Roadmap
A role-readiness roadmap for backend, cloud, data, AI API, and production infrastructure skills.
Why I'm Building an AI Infrastructure Learning OS
A personal operating system for turning backend and AI infrastructure learning into durable, searchable engineering knowledge.
Week 1: Backend Infrastructure Ramp
A first weekly learning log for backend, deployment, security, observability, and AI infrastructure readiness.
Backlinks
API Design Checklist
A practical checklist for reliable HTTP API design.
Backend and AI Infrastructure Roadmap
A role-readiness roadmap for backend, cloud, data, AI API, and production infrastructure skills.
LLM API Integration Patterns
Reliability patterns for OpenAI, Anthropic, OpenRouter, and other model APIs.