Introduction
APIs are the backbone of modern software architecture. Whether you're building a backend for a mobile app or exposing services for third-party developers, a clean and intuitive API makes integration a breeze.

Unfortunately, many APIs fall into common design traps that make them confusing, brittle, and hard to maintain. Let's look at four anti-patterns and how to fix them.

Anti-Pattern 1: Using Verbs in URIs
REST is all about resources, not actions. Your URLs should represent nouns (collections or individual resources), and your HTTP methods (GET, POST, PUT, DELETE) should handle the actions.

❌ Bad:

POST /getUsers

POST /updateUser/5

GET /deleteUser/5

✅ Good:

GET /users (Retrieves all users)

PUT /users/5 (Updates user 5)

DELETE /users/5 (Deletes user 5)

Anti-Pattern 2: Ignoring Proper HTTP Status Codes
Returning a 200 OK status code for every response—even when an error occurs—forces client applications to parse the body just to see if a request failed.

Standard Status Codes to Use:

200 OK: Standard success response for GET, PUT, or PATCH.

201 Created: Success response when a resource is successfully created via POST.

204 No Content: Success response for a DELETE request with no body to return.

400 Bad Request: Malformed syntax or validation failure on the client side.

401 Unauthorized: Missing or invalid authentication credentials.

403 Forbidden: Authenticated user doesn't have permission for the action.

404 Not Found: The requested resource does not exist.

500 Internal Server Error: Unhandled server-side crash.

Anti-Pattern 3: Inconsistent Error Payloads
When an error occurs, clients need a predictable structure to display messages or handle retries. Returning a raw string text in one endpoint and a nested JSON object in another frustrates frontend developers.

✅ Consistent Error Payload Example:

JSON
{
"error": {
"code": "VALIDATION_ERROR",
"message": "The 'email' field is required and must be a valid email address.",
"status": 400
}
}
Anti-Pattern 4: Forgetting Pagination, Filtering, and Sorting
If an endpoint like GET /products returns 50,000 items in a single array response, your database and client memory will crash.

The Fix: Always implement query parameters for collection endpoints:

Pagination: /products?page=2&limit=20 or cursor-based pagination (/products?cursor=eyJpZCI6MTAwfQ==).

Filtering: /products?category=electronics&status=in-stock

Sorting: /products?sort=-price (descending price)

Conclusion
Clean REST API design is an act of empathy for the developers consuming your service. By relying on proper resource naming, correct HTTP status codes, consistent error payloads, and built-in pagination, you build APIs that are resilient and developer-friendly.