RANDOM

Custom Dice API

GET/dice/:sides

Roll dice with a configurable number of sides.

No signup or API key required.

Parameters

sidesintegerrequired · path
Number of sides on each die, from 2 to 1000.
countintegeroptional · query
Number of rolls, from 1 to 100. Omit for one result. Supplying count, including count=1, returns results and a total.
formatenumoptional · query
Response format. Defaults to json.
jsontext

No request body. Unknown or repeated query parameters return HTTP 400.

Returns 200 OK

A JSON object. Its structure depends on whether count is supplied, including count=1.

sidesinteger
The requested number of sides.
resultinteger
One roll from 1 through sides. Present only without count.
resultsarray<integer>
Individual rolls, each from 1 through sides. Length equals count. Present only with count.
totalinteger
Sum of results. Present only with count.

Plain text

With format=text: One roll. With count, a comma-separated list without sides or total.

Errors

Validation and service errors always return JSON, including when format=text.

errorstring
A machine-readable error code, such as invalid_parameter or rate_limited.
messagestring
A description of the problem.

400 Invalid parameters.

414 Query string exceeds 2048 characters.

429 Rate limit reached. Wait the seconds in Retry-After before retrying.

Usage notes

sides: integer 2..1000. Optional count: integer 1..100. Without count, returns sides and result. Text with count is a comma-separated list.

Roll a d20 for a tabletop demo or choose any supported die size. Add count to roll several dice and receive the individual results and sum.

Responses are not cached. Browser requests are supported through open CORS.

120 requests per minute per IP, with up to 30 per 10 seconds, shared across APIs. Limits are approximate per Cloudflare location. Full usage limits ↗