RANDOM
Coin Flip API
/coinFlip a virtual coin and receive heads or tails as JSON.
No signup or API key required.
Parameters
countintegeroptional · query- Number of coins to flip, from 1 to 100. Omit for one result. Supplying count, including count=1, returns results with heads and tails totals.
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.
resultstring- One outcome: heads or tails. Present only when count is omitted.
resultsarray<string>- One outcome per flip, each heads or tails. Length equals count. Present only when count is supplied.
headsinteger- Number of heads in results. Present only with count.
tailsinteger- Number of tails in results. heads + tails equals count. Present only with count.
Plain text
With format=text: One outcome, heads or tails. With count, a comma-separated list without totals.
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
Heads or tails. Optional count: integer 1..100. /coin?count=3 returns results plus heads and tails totals. Without count, returns one result. Text with count is a comma-separated list.
Settle a friendly tie, assign a random starting player, or prototype a coin-toss animation. Use count when you need several flips in one request.
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 ↗