Beginner LevelREST APIs & Web Services
What are RESTful Resource Naming Conventions and URL path structures?
❓ Interview Prompt: Explain clean URI design rules, plural nouns, hierarchical relationships, and avoiding RPC-style verbs in paths.
RESTful APIs center around Resources represented by clean, predictable URIs:
URI Naming Rules:
1
Use Plural Nouns: '/api/v1/users' instead of '/api/v1/user'.
2
Avoid Action Verbs: Use '/api/v1/orders' with 'DELETE' instead of '/api/v1/deleteOrder' (RPC style).
3
Use Hyphens for Readability: '/api/v1/user-profiles' (avoid underscores or camelCase).
4
Express Hierarchy: '/api/v1/users/42/orders/101' (Order 101 belonging to User 42).
5
Lowercase Letters: URIs are case-sensitive; keep all path segments strictly lowercase.
Code Implementation Example
http
GET /api/v1/products # Fetch list of products
POST /api/v1/products # Create new product
GET /api/v1/products/88 # Fetch product 88
PUT /api/v1/products/88 # Replace product 88
DELETE /api/v1/products/88 # Remove product 88
GET /api/v1/products/88/reviews # Fetch reviews for product 88💡Clean RESTful URI naming hierarchy for product resources.
🎯 Interview Key Takeaway
URIs should use plural nouns and hierarchical structures while relying on HTTP verbs to express CRUD actions.
#URI Design#REST API#Naming Conventions#Beginner
Back to all REST APIs & Web Services Questions→