Randomizer API Documentation

The randomizer API is a collection of random item generators that can be used for various logical or random decision making applications.

Contents

  1. Object Properties & Structure
  2. Operating Modes
    1. Simple Random Number
    2. Flip Coin
    3. Roll Dice
    4. Rock, Paper, Scissors
  3. Use Limits

1. Object Properties

The randomizer API will output a JSON object with various properties depending on the selected operating mode. See each section below for examples.

2. Operating Modes

There are several API modes depending on the type of data you want to retrieve.

i. Simple Random Numbers

https://api.viewbits.com/v1/randomizer?mode=simple

Use this call to return simple random numbers with timestamp. You can control the output and return a maximum of 6 items with the following parameters:

User InputDescription
qty*Number of random items to return. Default: 1. Max: 6.
minRandom number minimum value. Default: 0.
maxRandom number maximum value. Default: 100.
*key required

The API will output a JSON object with the following properties:

PropertyDescription
timestampCreation date in UNIX timestamp format.
dataArray of random numbers based on input parameters.
resultTotal of all random numbers in data array.

Examples:

1. Return a simple random number:

https://api.viewbits.com/v1/randomizer?mode=simple

{"timestamp":1708006516,"data":[39],"result":39}

2. Return a random number between 100 and 1000:

https://api.viewbits.com/v1/randomizer?mode=simple&min=100&max=1000

{"timestamp":1708006801,"data":[765],"result":765}

3. Return 4 random numbers between 500 and 10000:

https://api.viewbits.com/v1/randomizer?mode=simple&min=100&max=1000&qty=4&key=[YOUR_KEY] 

{"timestamp":1708006930,"data":[6892,9954,608,6860],"result":24314}

ii. Flip Coin

https://api.viewbits.com/v1/randomizer?mode=flipcoin

Use this call to replicate a coin flip. You can return up to 6 flips and get a result based on the most number of flips.

User InputDescription
qty*Number of coin flips to return. Default: 1. Max: 6.
*Key Required

The result is a JSON object with the following properties:

PropertyDescription
timestampCreation date in UNIX timestamp format.
dataArray of random coin flips.
headsCountNumber of head results.
tailsCountNumber of tails results.
resultWinner based on number of results.

Examples:

1. Return a single coin flip:

https://api.viewbits.com/v1/randomizer?mode=flipcoin

{"timestamp":1708010777,"data":["Heads"],"headsCount":1,"tailsCount":0,"result":"Heads"}

2. Return 3 coin flips and get the best 2 out of 3:

https://api.viewbits.com/v1/randomizer?mode=flipcoin&qty=3&key=[YOUR_KEY]

{"timestamp":1708007399,"data":["Tails","Heads","Tails"],"headsCount":1,"tailsCount":2,"result":"Tails"}

iii. Roll Dice

https://api.viewbits.com/v1/randomizer?mode=rolldice

Use this call to replicate rolling dice. You can return up to 6 rolls and get a total.

User InputDescription
qty*Number of dice to roll. Default: 1. Max: 6.
*Key Required

The result is a JSON object with the following properties:

PropertyDescription
timestampCreation date in UNIX timestamp format.
dataArray of dice rolls.
resultTotal number of all rolls.

Examples:

Return a single dice roll:

https://api.viewbits.com/v1/randomizer?mode=rolldice 

{"timestamp":1708008637,"data":[3],"result":3}

Roll three dice:

https://api.viewbits.com/v1/randomizer?mode=rolldice&qty=3&key=[YOUR_KEY] 

{"timestamp":1708008709,"data":[4,4,5],"result":13}

iv. Rock, Paper, Scissors

https://api.viewbits.com/v1/randomizer?mode=rps

Use this call to replicate a game of Rock, Paper, Scissors.

User InputDescription
moveUser move (r = rock, p = paper, s = scissors). Default = r.

The result is a JSON object with the following properties:

PropertyDescription
timestampCreation date in UNIX timestamp format.
userMoveUser’s move.
compMoveComputer’s move.
resultGame result.

Example

https://api.viewbits.com/v1/randomizer?mode=rps&move=p 

{"timestamp":1708008840,"userMove":"Paper","compMove":"Rock","result":"You win!"}

3. Use Limits

When no API key is provided, calls are limited to 5 per 30 second period. To increase rate limits and disable CORS, you must provide an API key by adding &key=[YOUR_KEY] to the end of your call.

Example: https://api.viewbits.com/v1/randomizer?mode=[SELECTION]&key=[YOUR_KEY]