This is the set of guidelines that I use to build my API's. Borrows heavily from Google's API Design Guide and Github's REST Api Docs.
- List endpoints with HTTP Verb, expected input, and reponse message and data types
Client errors generated by the API fall into one of three categories:
-
Invalid format. e.g. Expected JSON but received String
-
Invalid fields. e.g. Expected
project_id
but receivedtag_id
-
Invalid field values. e.g. Expected
project_id: <Number>
but receivedproject_id: <String>
.
Codes follow Google API Design Guide. You can see a full list of Error Codes here: https://cloud.google.com/apis/design/errors#handling_errors
All errors should follow this format, where the properties are defined in a constants
file.:
{
code: errCode.ERROR_CODE,
name: errName.ERROR_NAME,
message: errMsg.ERROR_MESSAGE
}
All successful responses should follow this format:
{
code: 200,
message: 'Success'
}