RESTful URL Design Best Practices
URL design, resource naming, plural nouns, nested resources, URL hierarchy, anti-patterns, kebab-case
RESTful URL Design Best Practices
URL design is one of the most visible aspects of a REST API. A well-designed URL structure is self-documenting — developers understand what a resource is and how to interact with it just by reading the URL. Poor URL design creates confusion, inconsistency, and maintenance problems.
Use Nouns, Not Verbs
The most common URL design mistake is using verbs in resource paths. REST already has verbs — they are the HTTP methods. Your URLs should describe resources (nouns), not actions (verbs).
BAD: GET /getUsers
BAD: POST /createUser
BAD: DELETE /deleteUser?id=42
GOOD: GET /users
GOOD: POST /users
GOOD: DELETE /users/42Use Plural Nouns for Collections
Collections should always be plural: /users, /products, /orders. This consistency simplifies client code — developers always know a collection endpoint is the plural form of the resource name. Individual resources are accessed by appending an identifier: /users/42.
Use Kebab-Case for Multi-Word Resources
When a resource name consists of multiple words, use kebab-case (hyphens): /blog-posts, /shipping-addresses, /payment-methods. Never use camelCase or underscores in URLs. Hyphens are URL-safe and improve readability.
Model Relationships with Nested Resources
When one resource belongs to another, model the relationship in the URL hierarchy:
GET /users/42/orders — all orders for user 42
GET /users/42/orders/7 — specific order 7 for user 42
POST /users/42/orders — create a new order for user 42Avoid nesting more than two levels deep. If you need deeply nested paths, consider flattening the design and using query parameters for filtering.
Keep URLs Lowercase
URLs are case-sensitive on most servers. Always use lowercase to avoid confusion: /api/users not /API/Users. Inconsistent casing leads to hard-to-find bugs and broken links.
Do Not Include File Extensions
Avoid /users.json or /users.xml. Use the Accept header for content negotiation instead. File extensions leak implementation details and make versioning harder.
