NewAPIVerve Academy: free courses and certifications anyone can verify.Explore the Academy →

Coin Flipper API

GET

Run coin flip simulations with heads and tails outcome tracking.

Coin Flipper simulates random coin flips and records heads or tails outcomes with flip counts. Paid plans can simulate multiple flips per request and calculate percentages, streak lengths, and fairness indicators.

Try it — live request, no key required

Request
GETapi.apiverve.com/v1/coinflipper
Verification
Format

No key required to try it. Get a key to use it in your app.

Example
{
  "status": "ok",
  "error": null,
  "data": {
    "total_flips": 10,
    "flips": [
      "Tails",
      "Heads",
      "Heads",
      "Tails",
      "Tails",
      "Heads",
      "Tails",
      "Tails",
      "Tails",
      "Tails"
    ],
    "heads_count": 3,
    "tails_count": 7,
    "heads_percentage": 30,
    "tails_percentage": 70,
    "longest_streak": {
      "length": 4,
      "type": "Tails"
    },
    "first_flip": "Tails",
    "last_flip": "Tails",
    "is_fair": false
  }
}

About the Coin Flipper API

A coin flip API for apps, games and lessons that need a heads or tails result they can log. Each toss uses fair probability (50/50), and the response lists every result in order with the heads and tails counts and the first and last flip, so a coin toss can be shown, stored or replayed exactly as it happened.

The Free plan flips one coin per request. That covers a tie-breaker button, choosing who goes first in a game, a random yes or no in a chat bot, or a coin flipper widget on a web page.

Paid plans let you set how many coins to flip, up to 10,000 in one call, and add the statistics that make a large batch worth having: heads and tails percentages, the longest streak and which side it was, and a fairness indicator that shows whether the split stayed close to even. That suits probability lessons, simulations, testing code that consumes random outcomes, and showing how streaks appear in genuinely random sequences.

How it works

Each flip draws one pseudo-random number and calls it Heads when the value is below 0.5 and Tails otherwise, so both sides have the same chance and no flip depends on the one before it. flips holds the results in the order they were generated, total_flips is how many were made, and heads_count and tails_count always add up to it. first_flip and last_flip are the first and last entries of that array.

The flips parameter defaults to 1 and accepts up to 10,000. Larger values are capped at 10,000, and values below 1 are treated as 1. The array grows with the count, so a 10,000-flip response carries 10,000 strings.

heads_percentage and tails_percentage are the counts divided by total_flips, times 100, rounded to two decimals: 30 means 30%, not 0.30. longest_streak scans the sequence for the longest run of identical results; length is the run size and type is the side. When two runs tie, the earlier one is reported, and a single flip has a streak of 1.

is_fair is true when the heads percentage is strictly within 10 percentage points of 50. It is a fixed tolerance band, not a statistical test, so small batches often read false: three heads in ten flips is 30% and returns false although nothing is wrong with the generator. Judge fairness on large batches.

On the Free plan the flips parameter is removed, so every call makes exactly one flip, and the percentage fields and is_fair are null.

What people use it for

Decision Making
Make random decisions and choices using fair coin flip probability
Gaming
Implement coin flip mechanics for games, sports, and random selection features
Probability Teaching
Demonstrate probability concepts and random distributions in education
Simulations
Run probability experiments and test statistical concepts with multiple flips

Without writing code

The Coin Flip widget from WidgetSpark flips one on your desktop.

Ways to call it

One endpoint, many ways in — REST with JSON, XML, YAML and CSV, plus GraphQL and an MCP interface for AI agents.

JSON
Default REST response
XML
Markup format
YAML
Human-readable
CSV
Tabular export
Beta
GraphQL
Query language
New
MCP
For AI agents

Other ways to use Coin Flipper

Same data, same APIVerve account, same credit balance — one key works on all of them.

Questions.

Common questions about the Coin Flipper API.

Read the docs →
How many coin flip simulations does the Free plan cover?
The Free plan provides 200 credits each month, covering 200 simulations at 1 credit per call. For higher volumes, the Starter plan covers up to 200,000 simulations per month, which works out to about $0.15 per 1,000 calls.
Are streak lengths and fairness scores included on the Free plan?
No, longest streak length, streak type, percentage distributions, and the fairness indicator are premium fields. Any paid plan unlocks these statistics alongside access to custom batch flip parameters.
Can I set a custom number of flips on the Free plan?
No, the flips parameter is restricted to paid plans. Free plan requests run using the default simulation count, while upgrading to Starter or above allows you to pass a custom flip count per call.
Does the API return each individual flip outcome?
Yes, the response provides an array of individual results marked as Heads or Tails. You also get dedicated fields for the first flip, the last flip, and aggregate counts for both outcomes across the simulation.
Can this API be used to analyze coin toss streaks?
Yes, on paid plans. Coin Flipper tracks consecutive flip streaks across multi-coin simulations. It reports the length of the longest streak and identifies whether it consisted of consecutive heads or tails.

Ready to build with Coin Flipper? Start with 200 free credits — one key unlocks all 300+ APIs.

Explore the catalog

300+ APIs on the same key and the same response shape.

Browse all APIs