# API Pricing & Credits

## Overview

prediction.click offers a paid API at `api.prediction.click` for programmatic access to real-time fair values, market data, and trading signals.

API keys are **free to create** — connect your wallet at [prediction.click/api-keys](https://prediction.click/api-keys) and your key is auto-generated. To make API calls, you need **credits**, purchased with USDC.

## Tiers

|             | Beginner          | Basic             | Pro               |
| ----------- | ----------------- | ----------------- | ----------------- |
| Rate Limit  | 3 req/s           | 10 req/s          | 50 req/s          |
| Price       | $50 / 1M requests | $30 / 1M requests | $20 / 1M requests |
| Min Deposit | $1 USDC           | $30 USDC          | $100 USDC         |

* API key starts with **0 credits** (API calls blocked until credits purchased)
* Purchasing a **Beginner** package → Beginner tier
* Purchasing a **Basic** package → Basic tier
* Purchasing a **Pro** package → upgrades to Pro tier
* Admin can manually change tier

## Credit Packages

| Package        | Credits    | Price (USDC) | Cost per 1M | Tier     |
| -------------- | ---------- | ------------ | ----------- | -------- |
| `beginner_20k` | 20,000     | $1           | $50         | Beginner |
| `basic_1m`     | 1,000,000  | $30          | $30         | Basic    |
| `basic_5m`     | 5,000,000  | $140         | $28         | Basic    |
| `pro_10m`      | 10,000,000 | $200         | $20         | Pro      |
| `pro_50m`      | 50,000,000 | $900         | $18         | Pro      |

## How to Purchase Credits

Credits are purchased via the **x402 payment protocol** — your wallet signs a USDC transfer on **Base network**. Gas fees for settlement are paid by the server, not the user.

### Browser

Visit [prediction.click/api-keys](https://prediction.click/api-keys), connect your wallet, and click a package's **Buy** button. Your wallet will prompt you to sign a USDC transfer.

### Programmatic (x402-fetch)

```typescript
import { wrapFetchWithPayment } from "x402-fetch"

const paidFetch = wrapFetchWithPayment(fetch, walletClient)

// Purchase Basic 1M credits ($30 USDC on Base)
const res = await paidFetch(
  "https://api.prediction.click/api/credits/purchase?package=basic_1m&wallet=0xYOUR_WALLET&network=base",
  { method: "POST" }
)
const { key, tier, credits } = await res.json()
```

## Using Your API Key

```bash
curl https://api.prediction.click/api/markets \
  -H "Authorization: Bearer pk_YOUR_KEY"
```

Or with `X-API-Key` header:

```bash
curl https://api.prediction.click/api/markets \
  -H "X-API-Key: pk_YOUR_KEY"
```

## Available Endpoints

| Endpoint                      | Description                                                  |
| ----------------------------- | ------------------------------------------------------------ |
| `/api/markets`                | All market data (6 assets × 4 timeframes)                    |
| `/api/fair-value/:asset/:tf`  | Fair value, sigma, spot, strike, edge, token IDs             |
| `/api/spot/:asset`            | Real-time Binance spot price + recent 1m candles (\~500)     |
| `/api/history/:asset/:tf`     | 1-second chart history                                       |
| `/api/opportunity/:asset/:tf` | Profitable fills from orderbook                              |
| `/api/orderbook/:asset/:tf`   | Orderbook depth (bids/asks)                                  |
| `/api/prediction-log`         | Prediction accuracy log (returns all; client-side filtering) |
| `/api/health`                 | System health status                                         |

## Rate Limits

| Access Method               | Limit              |
| --------------------------- | ------------------ |
| Frontend (prediction.click) | 600 req/min per IP |
| API Key — Beginner          | 3 req/s            |
| API Key — Basic             | 10 req/s           |
| API Key — Pro               | 50 req/s           |

Exceeding the rate limit returns **HTTP 429**. Credits exhausted returns **HTTP 402**.

## AI Agents

Give AI agents access to prediction.click data. See the [AI Skills reference](https://www.prediction.click/skill.md) for setup and usage details.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.prediction.click/reference/pricing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
