REST API Masterclass
Architecting Modern Backends01.Home02.What is REST?03.HTTP Deep Dive04.URI Best Practices05.JSON & Data Formats06.Environment Setup07.Your First Resource08.Advanced Controllers09.Database Strategy10.JWT Authentication11.Role-Based Auth (RBAC)12.API Versioning13.Filtering & Searching14.Pagination & Sorting15.Global Error Handling16.Rate Limiting17.CORS & Security18.Swagger & OpenAPI19.Testing with Supertest20.Webhooks & Caching21.Production Checklist
URI Design & Best Practices
Your URIs are the entry point to your system. They should be clean, consistent, and resource-oriented.
1. Use Nouns, Not Verbs
The HTTP method determines the action; the URI identifies the resource.
- ❌ Bad:
/getUsers,/createUser - ✅ Good:
GET /users,POST /users
2. Pluralize Your Resources
Keep it consistent across your entire API. Most professionals prefer plural nouns.
GET /customers
GET /customers/123
POST /orders3. Logical Nesting
Use nesting to show relationships, but don't go more than 2-3 levels deep.
# Get all comments for a specific post
GET /posts/123/comments
# Get a specific comment
GET /posts/123/comments/54. Filtering & Sorting
Don't create different URIs for different views of the same resource. Use query strings.
- ✅ Good:
/users?sort=desc&limit=10 - ❌ Bad:
/users/sorted/descending
The "Kebab-case" Standard: Use lowercase with hyphens for URIs (e.g.,
/user-profiles). It's more readable and avoids case-sensitivity issues in some servers.