# Coin Flipper API

> 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.

**Endpoint:** `GET https://api.apiverve.com/v1/coinflipper`  
**Category:** Games  
**Cost:** 1 credit per call  
**Canonical page:** https://apiverve.com/marketplace/coinflipper

## Overview

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.

## Authentication

Every call carries your key in an `x-api-key` header. The same key works across the whole
APIVerve catalog — there are no per-API subscriptions. Responses always use the same three
top-level keys: `status`, `error`, and `data`.

## Example request

```bash
curl "https://api.apiverve.com/v1/coinflipper?flips=10" \
  -H "x-api-key: YOUR_API_KEY"
```

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `flips` | integer | No | Number of coins to flip. default 1. range 1-10000. Premium field |

## Response fields

- `total_flips` — number · Total number of coin flips performed in simulation
- `flips` — array · Array of individual flip results as Heads or Tails
- `heads_count` — number · Total count of heads outcomes from all flips
- `tails_count` — number · Total count of tails outcomes from all flips
- `heads_percentage` — number · Percentage of heads outcomes as decimal · (premium)
- `tails_percentage` — number · Percentage of tails outcomes as decimal · (premium)
- `longest_streak` — object · The longest run of the same result anywhere in this set of flips
  - `longest_streak.length` — number · How many flips long that run was · (premium)
  - `longest_streak.type` — string · Which result the run was made of, Heads or Tails · (premium)
- `first_flip` — string · Result of the first coin flip performed
- `last_flip` — string · Result of the last coin flip performed
- `is_fair` — boolean · Statistical indicator of fair coin flip distribution · (premium)

## Sample response

```json
{
  "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
  }
}
```

## Use cases

- **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

## SDKs

- **npm** — `npm install @apiverve/coinflipper` (https://www.npmjs.com/package/@apiverve/coinflipper)
- **PyPI** — `pip install apiverve-coinflipper` (https://pypi.org/project/apiverve-coinflipper/)
- **NuGet** — `dotnet add package APIVerve.API.CoinFlipper` (https://www.nuget.org/packages/APIVerve.API.CoinFlipper)
- **Source** — https://github.com/apiverve/coinflipper-api

## More

- Full reference: https://docs.apiverve.com/ref/coinflipper
- Get an API key: https://dashboard.apiverve.com
- Full catalog: https://apiverve.com/marketplace
