There are four parts to the URI of a REST service: the host, context, API version, and the desired resource. {host}/{context}/{api-version}/{resource} Each part may be comprised of more granular elements and will be described in their respective sections. - Each of the URL elements listed above MUST use snake_case
HostThe host will be in the following format: The –qa indicator represents a non-production deployment. When no indicator is present then the stage is production. ContextThe API context is used to determine which API an incoming request is attempting to access. The API Context MUST be unique and snake_case. When viewing APIs in the store and publisher the API Name is used. The API Name should be unique and human friendly. It is our recommendation that the context be a URL-friendly version of your API Name. Often we suggest removing special characters and setting it to lower case. Some long API Names can also be abbreviated. It should be clear which API Name and API Context is referencing, so when a developer is reading code and finds the URL that is invoked, they can find that API in the store.
API VersionThe API version is used to determine which iteration of an API an incoming request is attempting to access. It is used in conjunction with the API context. API 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: 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. It is recommended to format the version like: v1, v2, etc. Optionally you can omit the “v” or include a minor version like: v1.2, 1.2, etc. However, minor versions shouldn’t cause breaking changes so minor versioning in the url is discouraged. ResourceThe resource URL element specifies an entity in the current context. A resource by itself represents a collection of entities. You can refer to a single entity by specifying a unique identifier. General ConventionsResources MUST use snake_case Resources SHOULD be nouns and not verbs Resources SHOULD be plural Concrete resources are better than abstract
Single Entity ResourceA specific resource entity can be targeted by adding the identifier to the URL. For example: The identifier MUST uniquely identify a specific resource entity. Compound Resource IdentifiersIf more than one identifier is needed to identify a resource, they MUST be concatenated with commas: Info |
---|
| /classes/CSE,100,SP18 instead of /classes/CSE/100/SP18SP18 Note: In the API manager and the OpenAPI specification, these should still be indicated as separate parameters e.g. /classes/{subjectCode},{courseNumber},{termCode} instead of /classes/{compoundId} |
Qualified Resource IdentifiersWhen there are multiple types of resource identifiers, it is a good practice to qualify the identifier. Info |
---|
| /employees/employee_id=123 or /employees/racfid=AAAZZZ |
Sub ResourcesSub resources are used to interact with entities that can be uniquely identified by a higher level resource and have a direct relationship to the higher level resource. For example: This sub resource could be used to create a comment and associate it with an article. Sub resources can also be identified with the same rules as top-level resources. For example: Query ParametersQuery parameters can be used to specify the desired format of a response, for example: filtering, paging, sorting, etc. Query parameters MUST be camelCase. |