REST (Representational State Transfer) is the architectural standard governing modern web web APIs. A well-designed RESTful API should be intuitive, consistent, secure, and predictable for client developers consuming your endpoints.
1. Resource Naming Conventions & URIs
URIs should represent nouns (resources) rather than verbs (actions). HTTP methods specify the action being performed.
Bad Practice (Verb-based URIs)
- /getAllUsers
- /createNewUser
- /deleteUser?id=10
Good Practice (Noun-based REST URIs)
- GET /api/v1/users
- POST /api/v1/users
- DELETE /api/v1/users/10
2. HTTP Verbs & Idempotency Rules
Idempotency means making multiple identical requests has the same side-effect on the server as making a single request.
| HTTP Method | Action | Idempotent? | Safe? |
|---|---|---|---|
GET |
Retrieve resource representation. | Yes | Yes |
POST |
Create a new resource. | No | No |
PUT |
Replace an existing resource completely (or create if missing). | Yes | No |
PATCH |
Partially update specified fields of an existing resource. | Depends | No |
DELETE |
Remove specified resource. | Yes | No |
3. HTTP Status Codes Standards
Always return accurate HTTP status codes so client software can handle errors predictably:
- 200 OK: Request succeeded; returning requested payload.
- 201 Created: Resource successfully created (used with
POST). - 204 No Content: Action succeeded, but no payload body returned (used with
DELETE). - 400 Bad Request: Invalid client payload or JSON validation error.
- 401 Unauthorized: Missing or invalid authentication token (JWT).
- 403 Forbidden: Authenticated user lacks permission to access resource.
- 404 Not Found: Target resource URI does not exist.
- 500 Internal Server Error: Unhandled backend exception or database failure.
4. Standardized JSON Error Response Format
Do not return plain text stack traces. Standardize JSON error outputs across all API endpoints:
"status": 400,
"error": "Bad Request",
"message": "Validation failed for user creation",
"timestamp": "2026-09-30T14:30:00Z",
"details": [
{ "field": "email", "issue": "Invalid email address format" }
]
}
5. Pagination, Sorting & Security
For endpoints returning collections of records, always implement offset or cursor pagination to protect server memory:
GET /api/v1/orders?page=2&limit=20&sort=-createdAt- Secure endpoints using
Authorization: Bearer <JWT_TOKEN>headers. - Implement rate limiting (e.g., 100 requests / minute) returning status
429 Too Many Requests.
Master Backend API Development with Telugu IT Tutorials
Learn Node.js, Express, Spring Boot, and Python Django REST framework in our live interactive courses. View Courses →