Here is a list of most common HTTP codes that are used in Restful API designs:
- 200 - OK
- 400 - Bad Request (Client Error) - a json with error and more details of the errors.
- 401 - Unauthorized
- 500 - Internal Server Error - a json with an error may return to the client without details to avoid security risk
- 202 (Accepted) - when no response returns, e.g. asyncronous processing is used
- 401 (Unauthorized) - when there is a problem with the client’s credentials
- 403 (Forbidden) - forbid access regardless of authorization state
- 404 (Not Found) - when a client’s URI cannot be mapped to a resource
Sample of 400 response:
{
"errors": [
{
"error": {
"code": "100000400",
"field": "transactionId",
"message": "transaction is required."
"link": "https://url link to a page with explanation"
}
}
]
}
|
Sample of 500 response:
{
"error": {
"code": "100000500",
"reference": "3344c2e4-d54c-5caf-a4ea-c342cb4cccad",
"message": "Server error."
}
}
|
HTTP Status Codes Usage Examples
API | Status Codes |
---|---|
200, 304, 400, 401, 403, 404, 406, 410, 420, 422, 429, 500, 502, 503, 504 | |
Stripe | 200, 400, 401, 402, 404, 429, 500, 502, 503, 504 |
Github | 200, 400, 422, 301, 302, 304, 307, 401, 403 |
Pagerduty | 200, 201, 204, 400, 401, 403, 404, 408, 500 |
NewRelic Plugins | 200, 400, 403, 404, 405, 413, 500, 502, 503, 503 |
Etsy | 200, 201, 400, 403, 404, 500, 503 |
Dropbox | 200, 400, 401, 403, 404, 405, 429, 503, 507 |
Spotify | 200, 201, 204, 304, 400, 401, 403, 404, 429, 500, 502, 503 |
Google Cloud | 200, 301, 304, 307, 308, 400, 401, 403, 404, 405, 409, 411, 412, 416, 429, 500, 501, 503 |
HipChat | 200, 201, 202, 400, 401, 403, 404, 405, 429, 500, 503 |
Telegram | 200, 303, 400, 401, 403, 404, 420, 500 |
200, 400, 401, 403, 503 | |
Uber | 200, 201, 400, 401, 403, 404, 406, 409, 422, 429, 500 |
Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!
ReplyDeleteweb developer