🚀 API Design Conventions Every Developer Should Follow

Whether you’re working on a solo project or collaborating in a team, consistent API design makes a huge difference in code quality, collaboration, and scaling.
Here are some battle-tested API conventions I personally recommend:

🔹 1. Use RESTful Routes Clearly
GET /products → Fetch all products
GET /products/:id → Fetch single product
POST /products → Create a product
PATCH /products/:id → Update product
DELETE /products/:id → Delete product

🔹 2. Stick to Naming Consistency
Use camelCase for JSON keys: { “productName”: “Shirt” }
Pluralize resource endpoints: /users, /orders
Avoid mixing verbs in URLs — use the method (GET, POST) to describe action.

🔹 3. Clear Status Codes
200 OK — Success
201 Created — New resource created
400 Bad Request — Invalid input
401 Unauthorized — Login required
404 Not Found — Resource doesn’t exist
500 Internal Server Error — Something broke ☠️

🔹 4. Include Pagination for Lists
http
CopyEdit
GET /products?page=1&limit=20
Respond with:
json
CopyEdit
{
“data”: […],
“meta”: { “total”: 200, “page”: 1, “limit”: 20 }
}

🔹 5. Version Your API
Keep your APIs backward compatible:
bash
CopyEdit
GET /api/v1/products

🔹 6. Return Meaningful Errors
json
CopyEdit
{
“error”: “Invalid request”,
“details”: [“productName is required”, “price must be a number”]
}

🔹 7. Validate Input Always
Don’t rely on the client — use server-side validation (Zod, Yup, Joi, etc.).

🔹 8. Use OpenAPI (Swagger) for Docs
Auto-generate and maintain interactive API docs. Your frontend team will love you ❤️

🎯 Remember: APIs are contracts. Clean, consistent design = happy developers and faster features.

0
Subscribe to my newsletter

Read articles from Michael Sholadiran directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Michael Sholadiran
Michael Sholadiran

Writing clean code, building scalable apps, and sharing lessons from working with React, Next.js, and frontend ecosystems.