Generator Utilities

Random Number

Generates cryptographically secure random integers within specified ranges via GET /v1/generate/random/number. Perfect for AI agents needing unpredictable values for testing, simulations, or game mechanics. Returns single integers or arrays, with customizable min/max bounds. Uses secure random number generation, not pseudo-random algorithms.

API Endpoint

GET /v1/generate/random/number

Code Examples

curl "https://tinyfn.io/v1/generate/random/number" \
  -H "X-API-Key: YOUR_API_KEY"
const response = await fetch('https://tinyfn.io/v1/generate/random/number', {
  headers: { 'X-API-Key': 'YOUR_API_KEY' }
});
const data = await response.json();
console.log(data);
import requests

response = requests.get('https://tinyfn.io/v1/generate/random/number',
    headers={'X-API-Key': 'YOUR_API_KEY'})
data = response.json()
print(data)

Use via MCP

Add to your AI agent

Connect your AI agent (Claude, Cursor, Windsurf, etc.) to TinyFn's generator tools:

{
  "mcpServers": {
    "tinyfn-generator": {
      "url": "https://tinyfn.io/mcp/generator",
      "headers": {
        "X-API-Key": "YOUR_API_KEY"
      }
    }
  }
}

Learn more about MCP setup →

FAQ

How do I generate a random number between 1 and 100?

Use GET /v1/generate/random/number?min=1&max=100. The endpoint returns a single integer within the inclusive range.

Can I generate multiple random numbers at once?

Yes, add a count parameter like ?count=5 to get an array of random numbers. Useful for batch operations in MCP tools.

What's the difference between this and Math.random() in JavaScript?

TinyFn uses cryptographically secure random generation, while Math.random() is pseudo-random and predictable. This tool provides true randomness for security-sensitive applications.

What are the default min and max values if not specified?

Default range is typically 0 to 100, but check the API documentation for exact defaults. Always specify ranges for predictable behavior.

How can Claude Code use this for generating test data?

Through MCP, Claude Code can call this tool to generate random user IDs, test scores, or sample data sets for database seeding and unit tests.

Try Random Number Now

Get your free API key and start using Random Number in seconds.

Get Free API Key