-
Notifications
You must be signed in to change notification settings - Fork 152
REST Resources URIs
URIs are composed of multiple parts.
URI = scheme "://" authority "/" path [ "? query ] [ "#" fragment ]
https://www.nbb.be/hello-world?param1=value1¶m2=value2#section1
In the above example:
- protocol/scheme: https://
- sub-domain: www
- domain: nbb.be
- path: /hello-world
- query string: ?param1=value1
- query parameters
- param1: value1 (key: value)
- param2: value2
- separator: &
- fragment: section1
The URIs MUST be:
- completely in lowercase
- with kebab/spinal case: a-super-uri (i.e., hyphens to separate elements)
- as flat as possible (resources should be just below the API entry point)
- api/v1/employees rather than api/v1/enterprise/department/service/division/employees
- ❌ do NOT cross-reference everything, there's no need to repeat the database relations in the URL representations
⚠️ links like /api/v1/employees/{uuid}/manager don't need to exist because there's already an identifier for that resource: /employees/{uuid}- ✅ instead, you can either nest other objects in the responses or provide links to those objects that's a tradeoff between client or server effort
- ✅ although, when in doubt, think about how you would display the data to a human user without API concerns
- no trailing forward slash ( / )
- no underscores ( _ )
This project is distributed under the terms of the EUPL FOSS license
REST Resources Design Workflow
REST Resources Single items and collections
REST Resources Many to many Relations
REST Resources Relations expansion
HTTP Status Codes Success (2xx)
HTTP Status Codes Redirection (3xx)
HTTP Status Codes Client Error (4xx)
HTTP Status Codes Server Error (5xx)
Pagination Out of range/bounds
Long-running Operations Example
Concurrency vs Delete operation
Caching and conditional requests About
Caching and conditional requests Rules
Caching and conditional requests HTTP headers
Error handling Example with a single error
Error handling Example with multiple errors
Error handling Example with parameters
Error handling Example with additional metadata
Bulk operations HTTP status codes
Bulk operations Resources naming convention
Bulk operations Creation example
Bulk operations Update example
Bulk operations Create and update example
File upload Simple file upload
File upload Simple file upload example
File upload Complex file upload
File upload Complex file upload example
REST Security General recommendations
REST Security Insecure direct object references