# Authentication (https://docs.predictorsdk.com/authentication)

Get an API key and send it with every request.

Every request carries an API key, except `GET /v1/plans`, which is public.

## Get an API key [#get-an-api-key]

1. Sign up at [app.predictorsdk.com](https://app.predictorsdk.com).
2. Open **API Keys** and click **Create API Key**.
3. Copy the key. It is shown only once.

The same page lets you revoke a key or roll it to a new value.

## Send it [#send-it]

Put the key in the `Authorization` header as a Bearer token. The SDKs do this
for you once you pass the key in:

  **cURL**
    ```bash
    curl -H "Authorization: Bearer YOUR_API_KEY" \
      "https://api.predictorsdk.com/v1/matching-markets/sports"
    ```
    **TypeScript**
    ```ts
    import { PredictorSDKClient } from "@predictorsdk/client";

    const client = new PredictorSDKClient({ token: "YOUR_API_KEY" });
    ```
    **Python**
    ```python
    from predictorsdk import PredictorSDK

    client = PredictorSDK(token="YOUR_API_KEY")
    ```
    **Go**
    ```go
    client := predictorclient.New(option.WithToken("YOUR_API_KEY"))
    ```
  
A request without a key, or with an unknown one, gets `401`. Keep keys out of
browser code and public repositories: anyone holding a key can spend your
plan's requests.

## Permissions [#permissions]

Keys created in the dashboard can call every endpoint in these docs. Each
endpoint checks one permission, and a key without it gets `403`:

| Permission | Endpoints |
|---|---|
| `markets.matching.read` | `GET /v1/matching-markets/sports`, `GET /v1/matching-markets/sports/lookup` |
| `markets.read` | `GET /v1/markets`, `GET /v1/categories`, `GET /v1/markets/{market_id}` |
| `events.read` | `GET /v1/events/{event_id}` |
| `crypto.prices.read` | `GET /v1/crypto-prices/binance` |
| `polymarket.wallet.read` | `GET /v1/polymarket/wallet` |
| `polymarket.positions.read` | `GET /v1/polymarket/wallet/positions` |

## Rate limits [#rate-limits]

Your plan sets how many requests a key can make per minute
(`rate_limit_per_min` on [`GET /v1/plans`](https://docs.predictorsdk.com/guides/plans)). Every authenticated
response reports it:

| Header | Meaning |
|---|---|
| `X-RateLimit-Limit` | Requests allowed in any rolling 60 seconds. Pace against this one. |
| `X-RateLimit-Remaining` | A rough guide only: it can repeat or even go up while you spend it. |
| `X-RateLimit-Reset` | A Unix time in seconds. |

Over the limit, the API answers `429` with `Retry-After` in seconds. The budget
refills gradually rather than all at once, so count your own requests over the
last 60 seconds instead of trusting `X-RateLimit-Remaining`.
[Error handling](https://docs.predictorsdk.com/guides/error-handling#building-a-local-limiter) shows a
limiter that works, and when to retry.