Restful Naming Conventions
title: "RESTful Naming Conventions — Resource and Field Naming Standards" description: "RESTful naming conventions standardize resource names as plural nouns, field names in snake_case, URI segments in kebab-case, and consistent parameter naming." date: 2026-06-28 lastmod: 2026-06-28 weight: 28 tags: [apis, restful] }
RESTful naming conventions define consistent rules for resource names, field names, URI segments, and query parameters to make APIs predictable and self-documenting.
What You'll Learn
- Resource naming rules
- Field and property naming
- URI and parameter naming
Why It Matters
Consistent naming is the foundation of API usability. Developers should predict endpoint names and field names without looking up documentation.
Naming Rules
| Element | Convention | Example |
|---|---|---|
| Resources | Plural nouns | /users, /orders |
| URI segments | kebab-case | /user-accounts |
| Query params | snake_case | ?sort_by=name |
| JSON fields | snake_case | {"first_name": "Alice"} |
| Enum values | snake_case | "payment_pending" |
| Request IDs | UUID | req-abc123-def456 |
Code Examples
# Resource naming
GET /users # Plural noun
GET /users/1 # Resource ID
GET /users/1/order-items # Nested (kebab-case)
POST /users # Create
PUT /users/1 # Update
# Query parameter naming
GET /users?sort_by=name # snake_case
GET /users?created_at__gte=2026-01-01 # Operators with __
# Response field naming
@app.route('/users/<int:id>')
def get_user(id):
return jsonify({
"user_id": id, # snake_case
"first_name": "Alice", # snake_case
"last_name": "Smith", # snake_case
"email_address": "alice@example.com", # snake_case
"account_status": "active", # snake_case
"created_at": "2026-06-28T00:00:00Z", # snake_case
"_links": { # underscore prefix for metadata
"self": f"/users/{id}",
"order_items": f"/users/{id}/order-items"
}
})
# Bad naming examples
GET /getUser # Verb, camelCase
GET /User # Singular, PascalCase
GET /users-list # Not a noun
POST /users/create # Verb in URL
// Naming convention enforcement
function validateNamingConvention(schema) {
const errors = [];
for (const [key] of Object.entries(schema.properties)) {
// Fields should be snake_case
if (!/^[a-z][a-z0-9_]*$/.test(key)) {
errors.push(`Field '${key}' should be snake_case`);
}
}
return errors;
}
// Middleware for consistent response naming
app.use((req, res, next) => {
const originalJson = res.json;
res.json = function(data) {
// Convert camelCase request body to snake_case
if (req.body && typeof req.body === 'object') {
req.body = camelToSnake(req.body);
}
next();
};
});
Common Mistakes
1. Mixed Casing Conventions
Some fields in camelCase, others in snake_case.
2. Verbs in Resource Names
Using /getUser instead of GET /users/1.
3. Inconsistent Plural/Singular
Mix of /users and /order in the same API.
4. Abbreviated Names
Using /usr instead of /users, or fn instead of first_name.
5. Special Characters in Names
Spaces, slashes, or dots in field names.
Practice Questions
- What naming convention should resources use?
- What naming convention should JSON fields use?
- What naming convention should URI segments use?
- Why avoid verbs in resource names?
- Why is consistency more important than the specific convention?
Answers:
- Plural nouns (kebab-case for multi-word).
- snake_case (lowercase with underscores).
- kebab-case (lowercase with hyphens).
- HTTP methods already express the verb.
- Any convention is fine as long as it's applied consistently.
Challenge: Create a naming convention document for your API. Include rules for resources, fields, parameters, and error codes.
FAQ
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro