Skip to main content

Random Number Generator API

MOCK DATA

Random integers or floats in any range — control decimal precision, draw guaranteed-unique values, and pin a seed for reproducible sequences.

Generated test data for fixtures and development

Base URL
/api/numbers
Capabilities
1 route Seedable
Last updated
July 29, 2026

GET /api/numbers

Live requestRuns against the public API
No key required
GET/api/numbers?count=10&seed=42

Request parameters

Lower bound, inclusive (between -1e9 and 1e9). Must be ≤ max. With type=int the effective lower bound is ceil(min).

Upper bound, inclusive (between -1e9 and 1e9). Must be ≥ min. With type=int the effective upper bound is floor(max).

int → whole numbers; float → decimals rounded to `precision` places.

Decimal places for type=float values (0–10). Defaults to 2. Ignored — with a warning — when type=int.

Guarantee all returned values are distinct (type=int only). Values come from a seeded affine permutation of the integer range, so they are evenly spread, not clustered-random, and seed-stable. The range must hold at least `count` integers; combining unique with type=float is a 400 (floats are effectively always unique).

Advanced response options5 options

How many records to generate (1–100).

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

Response format: json envelope, ndjson (one record per line) or csv.

Pretty-print the JSON response.

Drop the envelope: return the raw array/object without data/meta wrapper.

Response

Example parameters are ready. Send the request to inspect the live response.

Route reference

Code samples Ready-to-copy requests in 4 languages
Choose a code sample language
curl "https://randomapi.dev/api/numbers?count=10&seed=42"
const res = await fetch("https://randomapi.dev/api/numbers?count=10&seed=42");
const { data, meta } = await res.json();
import requests

data = requests.get("https://randomapi.dev/api/numbers?count=10&seed=42").json()["data"]
$json = json_decode(file_get_contents(
  "https://randomapi.dev/api/numbers?count=10&seed=42"
), true);
$data = $json["data"];
Parameters Route-specific request inputs 5
min float

Lower bound, inclusive (between -1e9 and 1e9). Must be ≤ max. With type=int the effective lower bound is ceil(min).

default: 0
allowed: -1000000000 – 1000000000
example: min=1
max float

Upper bound, inclusive (between -1e9 and 1e9). Must be ≥ min. With type=int the effective upper bound is floor(max).

default: 100
allowed: -1000000000 – 1000000000
example: max=50
type enum

int → whole numbers; float → decimals rounded to `precision` places.

default: int
allowed: int | float
example: type=int
precision int

Decimal places for type=float values (0–10). Defaults to 2. Ignored — with a warning — when type=int.

allowed: 0 – 10
example: precision=4
unique boolean

Guarantee all returned values are distinct (type=int only). Values come from a seeded affine permutation of the integer range, so they are evenly spread, not clustered-random, and seed-stable. The range must hold at least `count` integers; combining unique with type=float is a 400 (floats are effectively always unique).

default: false
example: unique=true
Universal parameters Shared response and formatting options 5
count int

How many records to generate (1–100).

default: 10
allowed: 1 – 100
example: count=3
seed int

Deterministic output: the same seed always returns the same records. Omit for random (the used seed is echoed in meta.seed).

example: seed=42
format enum

Response format: json envelope, ndjson (one record per line) or csv.

default: json
allowed: json | ndjson | csv
example: format=csv
pretty boolean

Pretty-print the JSON response.

default: false
example: pretty=true
unwrap boolean

Drop the envelope: return the raw array/object without data/meta wrapper.

default: false
example: unwrap=true
Response schema Fields returned in each record 1
value number

The random number: a whole number for type=int, a decimal rounded to `precision` places for type=float. Always within [min, max].

example: 42

Documented examples

Build-generated requests and complete responses
4
Ten reproducible integers between 0 and 100
GET /api/numbers?count=10&seed=42
{
  "data": [
    {
      "value": 48
    },
    {
      "value": 3
    },
    {
      "value": 86
    },
    {
      "value": 15
    },
    {
      "value": 84
    },
    {
      "value": 1
    },
    {
      "value": 8
    },
    {
      "value": 84
    },
    {
      "value": 45
    },
    {
      "value": 97
    }
  ],
  "meta": {
    "endpoint": "numbers",
    "count": 10,
    "seed": 42,
    "params": {
      "min": 0,
      "max": 100,
    …
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Three dice rolls
GET /api/numbers?min=1&max=6&count=3
{
  "data": [
    {
      "value": 3
    },
    {
      "value": 1
    },
    {
      "value": 6
    }
  ],
  "meta": {
    "endpoint": "numbers",
    "count": 3,
    "seed": 42,
    "params": {
      "min": 1,
      "max": 6,
      "type": "int",
      "unique": false
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Floats with 4 decimal places
GET /api/numbers?type=float&min=0&max=1&precision=4&count=5
{
  "data": [
    {
      "value": 0.4778
    },
    {
      "value": 0.0395
    },
    {
      "value": 0.857
    },
    {
      "value": 0.1544
    },
    {
      "value": 0.8337
    }
  ],
  "meta": {
    "endpoint": "numbers",
    "count": 5,
    "seed": 42,
    "params": {
      "min": 0,
      "max": 1,
      "type": "float",
      "precision": 4,
      "unique": false
    },
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}
Lottery draw: 10 unique numbers from 1–50
GET /api/numbers?unique=true&min=1&max=50&count=10&seed=7
{
  "data": [
    {
      "value": 43
    },
    {
      "value": 10
    },
    {
      "value": 27
    },
    {
      "value": 44
    },
    {
      "value": 11
    },
    {
      "value": 28
    },
    {
      "value": 45
    },
    {
      "value": 12
    },
    {
      "value": 29
    },
    {
      "value": 46
    }
  ],
  "meta": {
    "endpoint": "numbers",
    "count": 10,
    "seed": 7,
    "params": {
      "min": 1,
      "max": 50,
    …
    "generatedAt": "2026-07-29T08:13:22.000Z"
  }
}

About this API

Coverage & behavior

Draws random numbers from [min, max]both bounds inclusive. Two flavors:

  • type=int (the default) returns whole numbers. Fractional bounds tighten naturally: min=1.2&max=4.8 draws from 2–4 (ceil(min)floor(max)), and a range containing no whole number at all (say min=1.2&max=1.8) is an explicit 400 — never a silent guess.
  • type=float returns decimals rounded to precision places (default 2, up to 10). precision is meaningless for integers, so setting it with type=int adds a warning and is ignored.

Unique draws. unique=true (integers only) guarantees no repeats — sampling without replacement for lottery numbers, quiz questions or shuffled IDs. Values come from a seeded affine permutation of the integer range, so they are evenly spread across the whole range, not clustered-random, and the same seed reproduces the exact same sequence forever. The honesty rules: a range holding fewer integers than count is a 400 stating both numbers, and unique with type=float is a 400 too — floats are effectively always unique, so the flag would only mislead.

Every response echoes the resolved parameters (including the applied precision default) in meta.params.

Use it for

  • Dice rolls, loot tables and lottery draws — unique=true is sampling without replacement
  • Reproducible numeric test fixtures: pin a seed and assert exact values in CI
  • Mock prices, ratings or sensor readings with a fixed number of decimals

Frequently asked questions

How do I get unique numbers?

unique=true guarantees the returned set has no duplicates within one response.

Are the numbers cryptographically secure?

No — they come from a fast seeded PRNG built for reproducible test data. Don't use them for secrets; for key-shaped values see the tokens endpoint.

Can I control decimals?

type=float with precision fixes the decimal places; type=int gives whole numbers in [min, max].