Skip to main content
Complete reference for all Random Number Generator API endpoints, parameters, and response formats.

Base URL

https://api.sinaty.business/random/

Endpoints Overview

MethodEndpointDescription
GET/random/Generate random numbers with query parameters
POST/random/Generate random numbers with JSON body

GET /random/

Generate random numbers using query parameters.

Query Parameters

ParameterTypeDefaultDescription
mininteger1Minimum value (inclusive)
maxinteger100Maximum value (inclusive)
countinteger1Number of numbers to generate (1-10000)
uniquebooleantrueGenerate unique numbers
securebooleanfalseUse cryptographically secure random
sortedbooleanfalseSort the results

Example Request

curl "https://api.sinaty.business/random/?min=1&max=50&count=10&unique=true&sorted=true"

Response Format

{
    "numbers": [3, 7, 12, 15, 23, 28, 31, 35, 42, 47],
    "count": 10,
    "range": {
        "min": 1,
        "max": 50
    },
    "options": {
        "unique": true,
        "secure": false,
        "sorted": true
    },
    "timestamp": "2024-01-15 10:30:00",
    "statistics": {
        "sum": 243,
        "average": 24.3,
        "min_value": 3,
        "max_value": 47,
        "unique_count": 10
    }
}

POST /random/

Generate random numbers using JSON body parameters.

Request Body

{
    "min": 1,
    "max": 100,
    "count": 5,
    "unique": true,
    "secure": false,
    "sorted": false
}

Example Request

curl -X POST "https://api.sinaty.business/random/" \
  -H "Content-Type: application/json" \
  -d '{"min": 1, "max": 50, "count": 10, "unique": true, "sorted": true}'

Response Fields

FieldTypeDescription
numbersarrayArray of generated random numbers
countintegerNumber of numbers generated
range.minintegerMinimum value used
range.maxintegerMaximum value used
options.uniquebooleanWhether unique numbers were generated
options.securebooleanWhether secure random was used
options.sortedbooleanWhether results were sorted
timestampstringGeneration timestamp
statistics.sumnumberSum of all generated numbers
statistics.averagenumberAverage of all generated numbers
statistics.min_valueintegerMinimum value in generated numbers
statistics.max_valueintegerMaximum value in generated numbers
statistics.unique_countintegerNumber of unique values

Error Responses

Invalid Range (400)

{
    "error": "Minimum value must be less than maximum value",
    "details": "min: 100, max: 50"
}

Invalid Count (400)

{
    "error": "Count must be between 1 and 10000",
    "details": "Requested count: 15000"
}

Impossible Unique Generation (400)

{
    "error": "Cannot generate unique numbers",
    "details": "Requested 100 unique numbers from range 1-50"
}

Invalid Parameter Type (400)

{
    "error": "Invalid parameter type",
    "details": "Parameter 'min' must be an integer"
}

HTTP Status Codes

CodeDescription
200Success - Random numbers generated
400Bad Request - Invalid parameters
500Internal Server Error

Rate Limits

No rate limits! You can make unlimited requests to our API.

Parameter Constraints

Range Constraints

  • min and max must be integers
  • min must be less than max
  • Range can include negative numbers
  • Maximum range: -1,000,000 to 1,000,000

Count Constraints

  • count must be between 1 and 10,000
  • When unique=true, count cannot exceed the range size
  • Example: Cannot generate 100 unique numbers from range 1-50

Unique Generation

When unique=true:
  • All generated numbers will be different
  • Count cannot exceed the range size
  • Generation may be slower for large counts
When unique=false:
  • Numbers may be repeated
  • Faster generation
  • No count limitations beyond the 10,000 limit

Security Considerations

Secure vs Standard Random

  • Standard Random: Uses pseudo-random number generator (faster)
  • Secure Random: Uses cryptographically secure random (slower but more secure)
Use secure random for:
  • Security-critical applications
  • Cryptographic operations
  • Financial transactions
  • Lottery systems
Use standard random for:
  • Games and simulations
  • Testing and development
  • Performance-sensitive operations
  • Non-security-critical applications

Best Practices

Bulk Generation

For generating multiple numbers, use the count parameter instead of multiple API calls:
# Good - Single request
curl "https://api.sinaty.business/random/?count=1000&min=1&max=100"

# Avoid - Multiple requests
for i in {1..1000}; do curl "https://api.sinaty.business/random/"; done

Range Selection

Choose appropriate ranges for your use case:
  • Dice Simulation: min=1, max=6
  • Percentage: min=1, max=100
  • Binary Choice: min=0, max=1
  • Large Range: min=1, max=1000000

Unique vs Non-Unique

  • Use unique=true for: lottery numbers, sampling without replacement, unique IDs
  • Use unique=false for: dice rolls, coin flips, simulations with replacement

Sorting Considerations

  • Use sorted=true for: ordered lists, sequential processing, display purposes
  • Use sorted=false for: random order, gaming applications, simulations

Error Handling

Always implement proper error handling:
async function generateRandomNumbers(min, max, count) {
    try {
        const response = await fetch(
            `https://api.sinaty.business/random/?min=${min}&max=${max}&count=${count}`
        );
        
        if (!response.ok) {
            const error = await response.json();
            console.error('API Error:', error.error);
            console.error('Details:', error.details);
            return null;
        }
        
        const data = await response.json();
        return data.numbers;
    } catch (error) {
        console.error('Request failed:', error);
        return null;
    }
}

Performance Tips

Large Counts

For generating large numbers of random values:
  1. Use POST requests for better performance with complex parameters
  2. Consider unique=false if duplicates are acceptable
  3. Use standard random unless security is critical
  4. Avoid sorting unless necessary

Caching

Consider caching results for frequently used ranges:
const cache = new Map();

async function getRandomNumbers(min, max, count) {
    const key = `${min}-${max}-${count}`;
    
    if (cache.has(key)) {
        return cache.get(key);
    }
    
    const numbers = await generateRandomNumbers(min, max, count);
    cache.set(key, numbers);
    return numbers;
}
I