URIThere are three parts to the URI of a REST service: the host, the API, and the desired resource. {host}/{api-version}/{resource}
Each part may be comprised of more granular elements and will be described in their respective sections. The entire URI should be lowercase. The host is made up of a {base} and an {api context} : {base}/{api_context} {base} = http(s)://api[-dev|-qa].ucop.edu The -dev and –qa indicators represent stages in the development and delivery of the service. When no indicator is present then the stage is production. {api_context} is a context for the resource. API VersionAPI Version indicates breaking change in the interface (request or response) or functionality that prevents existing consumers from consuming this API successfully. - Version only when needed. A new version of API also requires multiple runtime binaries and many times, backend database changes.
- Work with clients to see if they can be upgraded without increasing the version
- Support at the most 2 versions
- Version if the response has breaking change as well.
How to version:There are different ways to version an API. Various techniques are based on indicating version number in - Headers
- URLs
- Headers & URLs both, using a Hybrid approach. Use the latest version by default unless a specific version is provided in the header or in URL
It is recommended to use URL based versioning as it specifically indicates what version is being used by the consumer. A version number should be appended to the host to allow for versioning of the resources. There are different ways to format the version. The recommendation is to use V1, V2, etc... (or v1). if the API Gateway software does not allow use of non-numeric version numbers, use 1, 2,3 etc. ResourceNaming Convention Info |
---|
The type of case are defined as follows: Camel case camelCase Snake case snake_case |
- URI MUST use snake case
- Resources MUST use snake case
- Query Parameter Keys MUST use camel case.
- Using camel case will reduce mapping effort between query parameter and backend variables
- Query Parameters Values are application specific
- Request Body MUST use camelCase
- Response Body MUST camelCase
- Resource names SHOULD be plural
- Resources SHOULD be nouns and not verbs
IdentificationA resource is the entity on which an operation is performed. For instance - Create, Read, Update, Delete - Concrete resources are better than abstract
- e.g. /dogs better than /animal
- Two URLs per resource are needed
- The first one is for a collection. Use plural to refer to collection
- e.g. /applications, /dogs etc.
- The second one is for an instance of a resource
- e.g. /applications/a1b2, /dogs/{id}
- If more than one identifier is needed to identify a resource, they MUST be concatenated with commas
- e.g. /classes/CSE,100,SP18 instead of /classes/CSE/100/SP18
- When there are multiple types of resource identifiers, it is a good practice to qualify the identifier.
- e.g. /employees/employee_id=123 or /employees/racfid=AAAZZZ
|