Rest API Design Rules
29 Mar 2012
I’have found some important rules need to consider for REST API design.
- Forward slash separator (/) must be used to indicate a hierarchical relationship.
- A trailing foreword slash (/) should not be included in URLs.
- Hyphens (-) should be used to improve the readability of URLs.
- Underscore should not be used in URLs.
- Lower case letters should be preferred in url paths
- File extensions should not be included in URLs
- Consistent sub domain names should be used for your api. I.e. http://API.domain.com
- Consistent subdomain names should be used for your client developer portal. I.e. http://developer.domin.com
- A singular noun should be used for document names.(a resource, an object instance or database records.)
- A plural noun should be used for collection names (collection of resource)
- A verb or verb phrase should be used for controller name (functions or actions)
- Variable path segments may be substituted with identity based value. I.e http://API.domin.com/users/(user Id)
13.CURD functions name should not be used in URLs.
14.the query parameter of URL may be used to filter collections.
- The query parameter of a URLs should be used to paginate collections results.