HTTP Status Codes API: The Complete Guide

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
1xxInformationalRequest received, continuing process
2xxSuccessRequest successfully received and processed
3xxRedirectionFurther action needed to complete request
4xxClient ErrorRequest contains bad syntax or cannot be fulfilled
5xxServer ErrorServer failed to fulfill valid request
Pro Tip: Always handle both 4xx and 5xx errors gracefully in your applications to provide good user experience.

Using the HTTP Status API

TinyFn provides an endpoint to look up HTTP status codes:

API Request
GET https://api.tinyfn.io/v1/http-status/404
Headers: X-API-Key: your-api-key
Response
{
  "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 All 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
200OKSuccessful GET/PUT request
201CreatedSuccessful POST creating a resource
204No ContentSuccessful DELETE request
301Moved PermanentlyURL has permanently changed
400Bad RequestInvalid request syntax
401UnauthorizedAuthentication required
403ForbiddenAccess denied
404Not FoundResource doesn't exist
500Internal Server ErrorServer-side error

Best Practices

  1. Use appropriate codes: Return the most specific status code for each situation
  2. Include error details: Provide helpful error messages alongside status codes
  3. Handle all categories: Implement handling for 2xx, 4xx, and 5xx responses
  4. 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

Ready to try TinyFn?

Get your free API key and start building in minutes.

Get Free API Key