
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
minandmaxcan be numbers or numeric strings. Use strings for very large values or exact decimals.numbersis an array of strings, so large values and trailing zeros survive. WithdecimalPlaces: 2you get values like"3.50".- Set
allowDuplicatestofalsefor a draw without repeats (like a lottery). The range must then hold at leastcountdistinct values. - Up to 10000 numbers per request and up to 10 decimal places.
Endpoints
POST
https://opentools.ca/api/v1/tools/random-number-generatorGenerate random numbers in a range
Request Body
Content-Type: application/json
| Parameter | Type | Required | Description |
|---|---|---|---|
| min | number | string | Optional | Lowest value, inclusive.Default: 1 |
| max | number | string | Optional | Highest value, inclusive. Must be at least min.Default: 100 |
| count | number | Optional | How many numbers to draw, 1 to 10000.Default: 1 |
| decimalPlaces | number | Optional | Decimal places, 0 to 10. 0 gives whole numbers.Default: 0 |
| allowDuplicates | boolean | Optional | When false, no value appears twice.Default: true |
| sort | string Enum: none, asc, desc | Optional | Order 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 holds401
Unauthorized - Invalid or missing API key403
Forbidden - API key inactive, expired, or request from a disallowed IP429
Too Many Requests - Rate limit exceeded500
Internal Server ErrorCode 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"}'Rather use it in your browser? Open the Random Number Generator