APIs are architecture decisions
Your API style shapes client-server coupling, bandwidth usage, caching strategies, and developer experience. Choosing between REST, GraphQL, and gRPC isn't a preference — it's an architectural trade-off that affects every consumer of your service.
REST — the proven default
Resource-oriented URLs, HTTP verbs, and JSON payloads. REST's simplicity and tooling maturity make it the default for public APIs and CRUD-heavy services.
Strengths: Cacheable (HTTP caching, CDN), universal client support, easy to debug with curl.
Weaknesses: Over-fetching (clients get more data than needed), under-fetching (multiple round-trips for related resources), no built-in schema evolution.
GraphQL — flexible queries
Single endpoint, client-defined queries. Clients request exactly the fields they need, eliminating over/under-fetching. Schema-first design with strong typing and introspection.
Strengths: Precise data fetching, self-documenting schema, excellent for mobile apps with bandwidth constraints.
Weaknesses: N+1 query problems (use DataLoader), caching complexity (no HTTP caching out of the box), authorization per-field is tricky.
gRPC — high-performance RPC
Protocol Buffers serialization, HTTP/2 transport, bidirectional streaming. gRPC is 5-10x faster than JSON/REST for internal service-to-service communication.
Strengths: Binary format (smaller payloads), streaming support, code generation for 10+ languages, built-in deadlines and cancellation.
Weaknesses: Not browser-native (needs gRPC-Web proxy), harder to debug than JSON, protobuf schema management adds overhead.
Build your architecture diagram now
Datadef generates professional diagrams with AI — 2,000+ cloud icons, column-level data lineage, and an MCP server your coding agent can drive.
API gateway patterns
- Edge gateway: Kong, AWS API Gateway, or Traefik as a single entry point — handles auth, rate-limiting, and routing.
- BFF (Backend-for-Frontend): Separate API layers for web, mobile, and third-party consumers. Each BFF aggregates and shapes data for its client.
- Service mesh: Istio or Linkerd handle service-to-service communication (mTLS, retries, circuit-breaking) at the infrastructure layer.
Versioning strategies
URL versioning (/v1/users, /v2/users): explicit but clutters routes. Header versioning (Accept: application/vnd.api.v2+json): cleaner URLs but less discoverable. Query param versioning (?version=2): simple but not RESTful. Most teams use URL versioning for simplicity.
Rate limiting and throttling
Protect services with token-bucket or sliding-window rate limiting. Return 429 Too Many Requests with Retry-After headers. Differentiate limits by API key tier (free: 100 req/min, pro: 10,000 req/min). Implement at the gateway layer, not in individual services.