Skip to content
Live

API Design Best Practices in 2024

Design APIs that developers love. Covers REST conventions, versioning strategies, error handling, pagination, and the OpenAPI specification.

By Amara Osei10 min read

APIs Are Products

Your API is a product. Its consumers are developers. Design it with the same care you'd give a user interface — because it is one.

Resource Naming

Use nouns, not verbs. Use plural forms. Keep it consistent.

✓ GET    /articles
✓ GET    /articles/123
✓ POST   /articles
✓ PUT    /articles/123
✓ DELETE /articles/123

✗ GET /getArticles
✗ POST /createNewArticle

HTTP Status Codes

Use them correctly — they're part of your API contract:

200 OK           — Success
201 Created      — Resource created
204 No Content   — Success, no body
400 Bad Request  — Client error (validation)
401 Unauthorized — Not authenticated
403 Forbidden    — Authenticated but not allowed
404 Not Found    — Resource doesn't exist
422 Unprocessable — Validation failed
429 Too Many Requests — Rate limited
500 Internal Server Error — Your bug

Consistent Error Responses

{
  "error": {
    "code": "VALIDATION_ERROR",
    "message": "The request body is invalid.",
    "details": [
      { "field": "email", "message": "Must be a valid email address" }
    ]
  }
}

Pagination

{
  "data": [...],
  "pagination": {
    "page": 2,
    "perPage": 20,
    "total": 847,
    "totalPages": 43,
    "links": {
      "prev": "/articles?page=1",
      "next": "/articles?page=3"
    }
  }
}

Versioning

/v1/articles  — URL versioning (most visible)
Accept: application/vnd.api+json;version=1  — Header versioning

Document everything with OpenAPI. Generate client SDKs automatically. Your future self will thank you.

Share

Written by

Amara Osei

Writes on search, distribution, and how good work actually gets found.

performance

Web Performance: Beyond Core Web Vitals

Core Web Vitals are just the start. Learn advanced performance techniques including resource hints, code splitting, and the new INP metric.

Amara Osei11 min read
seo

SEO Fundamentals for Modern Web Apps

Core SEO principles every developer should know: structured data, Core Web Vitals, semantic HTML, and the Next.js Metadata API.

Amara Osei7 min read