REST API Interview Notes
What is REST?
REST is an architectural style for designing HTTP APIs around resources.
REST Principles
Client-Server, Stateless, Cacheable, Uniform Interface, Layered System.
HTTP Methods
GET(Read,idempotent), POST(Create), PUT(Replace,idempotent), PATCH(Partial update),
DELETE(Remove,idempotent).
Status Codes
2xx Success, 3xx Redirect, 4xx Client errors (400,401,403,404,409,422,429), 5xx Server errors
(500,502,503,504).
URI Design
Use nouns (/users), path params (/users/1), query params (?page=2&limit;=20&sort;=name).
Authentication
Sessions, JWT, OAuth.
Versioning
Prefer /v1/users for public APIs.
Pagination
Offset pagination and Cursor pagination.
Caching
Cache-Control, ETag, Last-Modified, Redis, CDN.
Rate Limiting
Token Bucket, Leaky Bucket, Sliding Window, Fixed Window.
Idempotency
Use Idempotency-Key for payment APIs.
Best Practices
Use proper HTTP methods/status codes, validate input, meaningful errors, HTTPS, versioning,
pagination, filtering, caching, logging, request IDs.