> ## Documentation Index
> Fetch the complete documentation index at: https://docs.predexon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Authentication

> How to authenticate with the Predexon API

## API Key

All requests require an API key passed in the `x-api-key` header. Sign up free at [dashboard.predexon.com](https://dashboard.predexon.com).

```bash theme={null}
curl -H "x-api-key: YOUR_API_KEY" \
  "https://api.predexon.com/v2/polymarket/markets?limit=10"
```

***

## Pay-per-call (x402)

The Data API can also be accessed via x402, the HTTP 402 Payment Required protocol. Pay per request, no signup or subscription required. Useful for agents and one-off integrations.

**Facilitator:** [Blockrun marketplace](https://blockrun.ai/marketplace/predexon)

***

## Plans (summary)

| Tier       | Rate Limit  | Monthly Requests | Price        |
| ---------- | ----------- | ---------------- | ------------ |
| Free       | 1 req/sec   | 1,000            | \$0/month    |
| Dev        | 20 req/sec  | 1,000,000        | \$49/month   |
| Pro        | 100 req/sec | 5,000,000        | \$249/month  |
| Enterprise | Custom      | Unlimited        | \$499+/month |

<Tip>
  **Most data is free.** Core market data, historical trades, orderbooks, and pricing endpoints are **free and unlimited** on all plans. The Trading API is entirely free on every plan.
</Tip>

For the full matrix — WebSocket limits, gated features, free-endpoint list, overage pricing — see [Rate Limits & Plans](/rate-limits) (the canonical reference) or [predexon.com/pricing](https://predexon.com/pricing).

<Warning>
  Exceeding rate limits returns `429 Too Many Requests`. Implement exponential backoff.
</Warning>

***

## Best Practices

<Tabs>
  <Tab title="Caching">
    Many endpoints return data that doesn't change frequently. Implement caching to reduce API calls:

    ```python theme={null}
    import requests, time

    BASE_URL = "https://api.predexon.com"
    cache = {}
    CACHE_TTL = 300  # 5 minutes

    def get_market(condition_id: str, api_key: str) -> dict:
        cache_key = f"market:{condition_id}"
        now = time.time()

        if cache_key in cache and cache[cache_key]["expires"] > now:
            return cache[cache_key]["data"]

        response = requests.get(
            f"{BASE_URL}/v2/polymarket/markets",
            params={"condition_id": condition_id},
            headers={"x-api-key": api_key}
        )
        data = response.json()
        cache[cache_key] = {"data": data, "expires": now + CACHE_TTL}
        return data
    ```
  </Tab>

  <Tab title="Retry Logic">
    Implement retries with exponential backoff for transient errors:

    ```python theme={null}
    import requests
    from requests.adapters import HTTPAdapter
    from urllib3.util.retry import Retry

    session = requests.Session()
    retries = Retry(
        total=3,
        backoff_factor=0.5,
        status_forcelist=[500, 502, 503, 504]
    )
    session.mount("https://", HTTPAdapter(max_retries=retries))
    ```
  </Tab>

  <Tab title="Connection Pooling">
    Reuse connections for better performance:

    ```python theme={null}
    BASE_URL = "https://api.predexon.com"

    session = requests.Session()
    session.headers.update({"x-api-key": "your_api_key"})

    # Reuse for all requests
    response = session.get(f"{BASE_URL}/v2/polymarket/markets")
    ```
  </Tab>
</Tabs>

***

## CORS

The API supports CORS for browser-based applications:

```javascript theme={null}
fetch("https://api.predexon.com/v2/polymarket/markets", {
  headers: { "x-api-key": "your_api_key" }
})
  .then(res => res.json())
  .then(data => console.log(data));
```

## Health Check

```bash theme={null}
curl "https://api.predexon.com/health"
# {"status": "healthy"}
```
