Random Number Generator

Random Number Generator API

Utilities

Generate truly fair random numbers in any range: whole numbers or decimals, one or thousands at once, with or without duplicates, sorted if you like.

Authentication

All API requests require a valid API key passed in the Authorization header as a Bearer token.

Rate Limit

120 requests per minute

Endpoints

1 endpoint available

Overview

Draw random numbers from an inclusive range. Numbers come from the server's crypto-secure random generator and every value in the range is equally likely. Decimals are exact, with no floating point.

Notes

  • min and max can be numbers or numeric strings. Use strings for very large values or exact decimals.
  • numbers is an array of strings, so large values and trailing zeros survive. With decimalPlaces: 2 you get values like "3.50".
  • Set allowDuplicates to false for a draw without repeats (like a lottery). The range must then hold at least count distinct values.
  • Up to 10000 numbers per request and up to 10 decimal places.

Endpoints

POST
https://opentools.ca/api/v1/tools/random-number-generator
Generate random numbers in a range

Request Body

Content-Type: application/json

ParameterTypeRequiredDescription
min
number | string
OptionalLowest value, inclusive.Default: 1
max
number | string
OptionalHighest value, inclusive. Must be at least min.Default: 100
count
number
OptionalHow many numbers to draw, 1 to 10000.Default: 1
decimalPlaces
number
OptionalDecimal places, 0 to 10. 0 gives whole numbers.Default: 0
allowDuplicates
boolean
OptionalWhen false, no value appears twice.Default: true
sort
string
Enum: none, asc, desc
OptionalOrder of the result.Default: none

Response Example

{
  "success": true,
  "min": "1",
  "max": "49",
  "decimalPlaces": 0,
  "count": 6,
  "numbers": [
    "4",
    "11",
    "23",
    "30",
    "38",
    "47"
  ]
}

Error Codes

400
Bad Request - Invalid number, max below min, count out of range, or more unique values requested than the range holds
401
Unauthorized - Invalid or missing API key
403
Forbidden - API key inactive, expired, or request from a disallowed IP
429
Too Many Requests - Rate limit exceeded
500
Internal Server Error

Code Examples

# Six lottery numbers from 1 to 49, no repeats
curl -X POST https://opentools.ca/api/v1/tools/random-number-generator \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"min": 1, "max": 49, "count": 6, "allowDuplicates": false, "sort": "asc"}'

Ready to get started?

Create an API key to start using the Random Number Generator API.

Rather use it in your browser? Open the Random Number Generator