# Credits and billing

> What costs what, and what is free.

One credit is one tweet or one profile returned to you. You buy credits in packs and spend them at any pace.

## Packs [#packs]

| Pack    | Price | Credits     | Per 1,000 |
| ------- | ----- | ----------- | --------- |
| Free    | $0    | 5,000, once | $0        |
| Starter | $10   | 80,000      | $0.125    |
| Builder | $50   | 500,000     | $0.100    |
| Growth  | $200  | 2,500,000   | $0.080    |
| Scale   | $600  | 10,000,000  | $0.060    |

Enterprise packs from $2,000 with invoice billing and a signed SLA: [hello@xdataapi.io](mailto:hello@xdataapi.io).

## Buying a pack [#buying-a-pack]

Card checkout runs on Stripe. Ask the API for a checkout link and open it:

```bash
curl -X POST https://api.xdataapi.io/v1/billing/checkout \
  -H "x-api-key: $KEY" -H "content-type: application/json" \
  -d '{"pack":"builder"}'
```

```json
{ "url": "https://checkout.stripe.com/c/pay/cs_...", "pack": "builder", "usd": 50, "credits": 500000 }
```

The credits land in the wallet within seconds of payment, and the rate limit rises to the pack's. Check with `/v1/me`.
Invoice billing for Enterprise: [hello@xdataapi.io](mailto:hello@xdataapi.io).

## Rules [#rules]

* **Credits never expire.** Paid or free, they stay in the wallet until you spend them.
* **No per-call minimum.** A request that returns nothing costs nothing.
* **Failed requests are free.** Any status other than `200` charges zero.
* **Cache hits cost half.** Responses are cached for a short time per endpoint; a hit is marked `"cache": "hit"`.
* **`fresh=true` bypasses the cache** at double the price.
* A charge never takes the balance below zero. At zero the API answers `402` with a link to buy more.
* One wallet per account. All packs land in the same balance; the oldest credits are spent first.
* Full refund of an unused pack within 14 days, on request to [hello@xdataapi.io](mailto:hello@xdataapi.io).

## Price per item [#price-per-item]

| Item                               | Credits           |
| ---------------------------------- | ----------------- |
| Tweet from any endpoint            | 1                 |
| Profile                            | 1                 |
| Follower or following entry        | 0.1               |
| Follower id, from the ids endpoint | 0.02              |
| Retweeter entry                    | 0.5               |
| Cached item                        | half of the above |
| `fresh=true` item                  | double the above  |
| Empty result, error, `404`, `403`  | 0                 |

## Reading the bill [#reading-the-bill]

Every response has `credits_charged` and `balance_remaining`. The same numbers are in the `x-credits-charged` and
`x-balance-remaining` headers, so a proxy can meter without parsing the body.

## SLA credit [#sla-credit]

For each full hour where the [status page](/status) shows success under 99.9 percent, every customer who made a failed
request in that hour gets 2 percent of their last pack back as credits. Applied automatically. The number that counts is
the outside probe, which calls the public API every minute from a different network.
