URI Design & Best Practices

Your URIs are the entry point to your system. They should be clean, consistent, and resource-oriented.

1. Use Nouns, Not Verbs

The HTTP method determines the action; the URI identifies the resource.

  • ❌ Bad: /getUsers, /createUser
  • ✅ Good: GET /users, POST /users

2. Pluralize Your Resources

Keep it consistent across your entire API. Most professionals prefer plural nouns.

GET /customers
GET /customers/123
POST /orders

3. Logical Nesting

Use nesting to show relationships, but don't go more than 2-3 levels deep.

# Get all comments for a specific post
GET /posts/123/comments

# Get a specific comment
GET /posts/123/comments/5

4. Filtering & Sorting

Don't create different URIs for different views of the same resource. Use query strings.

  • ✅ Good: /users?sort=desc&limit=10
  • ❌ Bad: /users/sorted/descending
The "Kebab-case" Standard: Use lowercase with hyphens for URIs (e.g., /user-profiles). It's more readable and avoids case-sensitivity issues in some servers.