Need to understand HTTP status codes in your application? This guide covers everything you need to know about looking up status codes via API, including all categories, common codes, and implementation examples.
What are HTTP Status Codes?
HTTP status codes are three-digit numbers returned by web servers to indicate the result of a client's request. They tell you whether a request succeeded, failed, or requires further action, and provide specific information about what happened.
Status codes range from 100 to 599 and are grouped into five categories based on their first digit.
Status Code Categories
HTTP status codes are divided into five classes:
| Range | Category | Meaning |
|---|---|---|
| 1xx | Informational | Request received, continuing process |
| 2xx | Success | Request successfully received and processed |
| 3xx | Redirection | Further action needed to complete request |
| 4xx | Client Error | Request contains bad syntax or cannot be fulfilled |
| 5xx | Server Error | Server failed to fulfill valid request |
Using the HTTP Status API
TinyFn provides an endpoint to look up HTTP status codes:
GET https://api.tinyfn.io/v1/http-status/404
Headers: X-API-Key: your-api-key
{
"code": 404,
"name": "Not Found",
"description": "The requested resource could not be found on this server.",
"category": "Client Error",
"is_error": true,
"is_success": false,
"specification": "RFC 7231",
"common_causes": [
"Mistyped URL",
"Deleted or moved resource",
"Broken internal link"
]
}
Parameters
| Parameter | Type | Description |
|---|---|---|
code |
integer | HTTP status code (100-599) |
List All Status Codes
GET https://api.tinyfn.io/v1/http-status
GET https://api.tinyfn.io/v1/http-status?category=4xx
Code Examples
JavaScript / Node.js
const response = await fetch(
'https://api.tinyfn.io/v1/http-status/500',
{ headers: { 'X-API-Key': 'your-api-key' } }
);
const status = await response.json();
console.log(`${status.code}: ${status.name}`);
console.log(status.description);
// Output: 500: Internal Server Error
// The server encountered an unexpected condition...
Python
import requests
response = requests.get(
'https://api.tinyfn.io/v1/http-status/201',
headers={'X-API-Key': 'your-api-key'}
)
status = response.json()
print(f"{status['code']}: {status['name']}")
print(f"Category: {status['category']}")
cURL
curl "https://api.tinyfn.io/v1/http-status/302" \
-H "X-API-Key: your-api-key"
Common Status Codes
| Code | Name | Common Use |
|---|---|---|
| 200 | OK | Successful GET/PUT request |
| 201 | Created | Successful POST creating a resource |
| 204 | No Content | Successful DELETE request |
| 301 | Moved Permanently | URL has permanently changed |
| 400 | Bad Request | Invalid request syntax |
| 401 | Unauthorized | Authentication required |
| 403 | Forbidden | Access denied |
| 404 | Not Found | Resource doesn't exist |
| 500 | Internal Server Error | Server-side error |
Best Practices
- Use appropriate codes: Return the most specific status code for each situation
- Include error details: Provide helpful error messages alongside status codes
- Handle all categories: Implement handling for 2xx, 4xx, and 5xx responses
- Log errors properly: Log 4xx and 5xx errors for debugging
Try the HTTP Status API
Get your free API key and start looking up status codes in seconds.
Get Free API Key