API Rest Conventions
API Rest Conventions
MasStack
Index
Main points to be defined
Defined
- Documentation in Dev Portal
- API Path conventions
- Basics of AuthN and AuthZ
- Recommended HTTP Codes
- Versioning Strategy
- Request and Response body conventions
- Error body definition
Next Steps
- Best practices II
- Standards (date, language, country, currency, etc)
- Common models - Ubiquitous language
- AuthZ - Permissions and roles
- Parse open api lib errors
- Error dictionary
- Pagination
2
Documentation
https://mas.fyi/documenting-best-practices
Developer Portal
Documenting best practices developers.masstack.com
3
Paths
API Gateway
api.masstack.com/vX/orgs/{org_id}/request_path
Naming
- English
- `snake_case`
4
AuthN & AuthZ
Request AuthN/AuthZ, Business & Application AuthnN
5
HTTP Codes
Recommended HTTP Codes
200 - GET resource success 308 - In deprecated API, 400 - POST, PUT & PATCH 500 - Internal server Error
200 - GET resource list success redirection to release note invalid body 501 - Not implemented (e.g.
200 - GET empty resource list 400 - GET query param invalid Method not developed)
success 401 - Unauthorized 502 - Bad gateway
201 - POST success 404 - GET item not found 503 - Service unavailable (e.g.
204 - PUT, POST, DELETE & 429 - Too Many requests maintaining, overload…)
PATCH success with empty 504 - Timeout
response
206 - GET resource list with
pagination*
This refers to the version number found in the URL path of any API request, for example:
catalogue.masstack.com/v2/orgs/{org_id}/commercial_profiles. This style of versioning is known as URI versioning.
Changes which must involve new API version Changes shouldn’t involve new API version
‘errors’: [
{
‘code’: ‘XXX_21201’,
‘title’: ‘TITLE_OF_THE_DOMAIN_ERROR’,
‘ref’: "https://developers.masstack.com/en/docs/apis_domain_doc_swagger/2/apioverview/#error’
‘details’: ‘message & details of the error’
}
]
9
Next Steps
Next points to be defined
10