Quick answer: A good REST API uses nouns for resources (/orders/42), the right HTTP methods (GET, POST, PUT/PATCH, DELETE), correct status codes, a consistent JSON error format, pagination, filtering, versioning, authentication over HTTPS, idempotency for payments, rate limiting and an OpenAPI specification. Consistency matters more than any single rule.

APIs are contracts. Once mobile apps, partners or government integrations depend on your API, every inconsistency becomes expensive to fix. These 15 practices apply to any stack – Laravel, ASP.NET Core, Node.js, Spring or Go.

1. Model resources with nouns

GET    /customers            list customers
POST   /customers            create a customer
GET    /customers/123        get one customer
PATCH  /customers/123        update some fields
DELETE /customers/123        delete
GET    /customers/123/orders orders of a customer

Avoid verbs like /getCustomers or /createOrder. For actions that are not CRUD, use a sub-resource: POST /orders/42/cancel.

2. Use HTTP methods correctly

Method

Purpose

Safe

Idempotent

GET

Read

Yes

Yes

POST

Create / action

No

No

PUT

Replace whole resource

No

Yes

PATCH

Partial update

No

Usually

DELETE

Remove

No

Yes

3. Return meaningful status codes

  • 200 OK, 201 Created (with Location header), 204 No Content.
  • 400 bad request, 401 not authenticated, 403 not allowed, 404 not found, 409 conflict, 422 validation failed, 429 too many requests.
  • 500 server error – never return 200 with "success": false.

4. One consistent error format

Use the standard Problem Details format (RFC 9457):

{
  "type": "https://api.example.com/errors/validation",
  "title": "Validation failed",
  "status": 422,
  "detail": "One or more fields are invalid.",
  "errors": { "email": ["The email field is required."] },
  "traceId": "00-4bf92f..."
}

5. Naming conventions

  • Plural resource names, lowercase, hyphens in URLs: /purchase-orders.
  • Pick one JSON casing (camelCase or snake_case) and never mix.
  • Dates in ISO 8601 UTC: 2025-03-01T09:30:00Z.
  • Money as integer minor units or decimal strings with currency: {"amount": "150.00", "currency": "SAR"} – never floats.

6. Pagination

  • Offset pagination is simple: ?page=2&per_page=25.
  • Cursor pagination scales better for large, changing data: ?cursor=eyJpZCI6MTAwfQ&limit=25.
  • Always cap the maximum page size.

7. Filtering, sorting and field selection

GET /orders?status=paid&created_from=2025-01-01&sort=-created_at&fields=id,total

8. Versioning

Use a version in the URL (/v1/) or a header. Only make a new major version for breaking changes; adding fields is not breaking. Announce deprecations with dates and a Sunset header.

9. Security basics

  • HTTPS only, HSTS enabled.
  • OAuth 2.0 / OpenID Connect or short-lived tokens; never API keys in URLs.
  • Check authorisation on every object (prevent IDOR: user A reading /orders/999 of user B).
  • Validate all input; limit body size.
  • Follow the OWASP API Security Top 10.

10. Idempotency for payments and orders

Clients send an Idempotency-Key header with POST requests. The server stores the key and returns the same response if the request is retried – so a network timeout never creates two payments.

11. Rate limiting

Return 429 with Retry-After, and expose limits with headers like RateLimit-Limit and RateLimit-Remaining.

12. Caching

Use ETag / If-None-Match and Cache-Control for read-heavy endpoints.

13. Document with OpenAPI

Write or generate an OpenAPI 3 spec, publish interactive docs (Swagger UI, Redoc, Scalar) and include examples for every endpoint and error.

14. Observability

Log a correlation/trace ID per request, return it in errors, and track latency, error rates and top consumers.

15. Webhooks for events

Instead of clients polling, send signed webhooks (HMAC signature + timestamp) with retries and an event ID for de-duplication.

Quick review checklist

  1. Nouns, plural, consistent casing?
  2. Correct methods and status codes?
  3. Problem Details errors with trace ID?
  4. Pagination limits and filters?
  5. Auth + object-level authorisation?
  6. Idempotency for money-moving endpoints?
  7. OpenAPI docs with examples?

Summary

Design APIs for the developer who will use them at 2 a.m. during an outage: predictable URLs, honest status codes, clear errors, safe retries and good documentation.