Status Codes Server

A simple Next.js server that returns HTTP status codes, formats Unix timestamps to ISO strings, and provides delay testing endpoints.

How to use

Status Codes API

Make a request to /api/[status] where [status] is the HTTP status code you want to receive.

Timestamp Formatting API

Make a request to /format/[timestamp] where [timestamp] is a Unix timestamp (seconds since epoch) to convert to ISO string format. Supports decimal precision for sub-second accuracy.

Delay API

Make a request to /api/delay to test network latency and timeouts. The endpoint introduces a random delay between 1-10 seconds before responding with a 200 OK status.

Random APIs

Fixed Probability: /api/random

Returns a 400 Bad Request status 25% of the time and a 200 OK status 75% of the time. Useful for testing random error handling with a fixed probability.

Custom Probability: /api/random/[probability]

Specify a decimal between 0 and 1 as the probability parameter. Returns a 500 status with probability equal to the parameter, otherwise returns 200 status.

Examples

GET /api/200

Returns a 200 OK response

GET /api/404

Returns a 404 Not Found response

GET /api/500

Returns a 500 Internal Server Error response

GET /format/1749478918.606359

Converts Unix timestamp to ISO string format

GET /api/delay

Returns a delayed response (1-10 seconds) for testing timeouts

GET /api/random

Returns 400 status 25% of the time, 200 status 75% of the time

GET /api/random/0.3

Returns 500 status 30% of the time, 200 status 70% of the time

GET /api/random/0.8

Returns 500 status 80% of the time, 200 status 20% of the time

Response Format

Status Codes API Response

{
  "status": 200,
  "message": "OK",
  "description": "The request has succeeded",
  "timestamp": "2023-12-15T10:30:00.000Z"
}

Timestamp Formatting API Response

{
  "timestamp": "2025-06-09T08:35:18.606Z"
}

Returns 400 error if timestamp is invalid

Delay API Response

{
  "status": 200,
  "message": "OK",
  "description": "The request has succeeded",
  "timestamp": "2023-12-15T10:30:00.000Z",
  "delay": 3450
}

The delay field indicates the milliseconds waited before response

Random Status API Response

Success (200):
{
  "status": 200,
  "message": "OK",
  "description": "The request has succeeded",
  "timestamp": "2023-12-15T10:30:00.000Z",
  "random": 0.7234
}

Error (400):
{
  "status": 400,
  "message": "Bad Request",
  "description": "The server cannot or will not process the request due to something that is perceived to be a client error",
  "timestamp": "2023-12-15T10:30:00.000Z",
  "random": 0.1234
}

The random field shows the generated value for transparency

Random Failure API Response

Success (200):
{
  "message": "Success"
}

Failure (500):
{
  "message": "Failure"
}

The response depends on the random outcome based on the probability parameter

Supported Methods

The API supports GET, POST, PUT, and DELETE methods. All methods return the same response format.

Valid Status Codes

Any HTTP status code between 100 and 599 is supported. The server includes detailed information for common status codes and generic information for others.