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

# Authentication

> How to authenticate with the PolyHistorical API

# Authentication

All API requests require an API key. Include your key in the `X-API-Key` header with every request.

## Getting your API key

1. [Create an account](https://polyhistorical.com/dashboard?tab=api-keys) (free, no credit card required)
2. Verify your email
3. Go to your [Dashboard](https://polyhistorical.com/dashboard) and navigate to **API Keys**
4. Click **Create New Key** and give it a name
5. Copy the key immediately -- it won't be shown again

## Using your API key

Include the key in the `X-API-Key` header:

<CodeGroup>
  ```bash cURL theme={null}
  curl -H "X-API-Key: nb_your_api_key_here" \
    "https://api.polyhistorical.com/v1/markets?coin=BTC&limit=5"
  ```

  ```python Python theme={null}
  import requests

  headers = {"X-API-Key": "nb_your_api_key_here"}
  response = requests.get(
      "https://api.polyhistorical.com/v1/markets",
      params={"coin": "BTC", "limit": 5},
      headers=headers
  )
  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const headers = { "X-API-Key": "nb_your_api_key_here" };

  const response = await fetch(
    "https://api.polyhistorical.com/v1/markets?coin=BTC&limit=5",
    { headers }
  );
  const data = await response.json();
  console.log(data);
  ```
</CodeGroup>

## API key limits by plan

| Plan           | Max API Keys |
| -------------- | ------------ |
| Starter (Free) | 1            |
| Pro            | 3            |
| Enterprise     | 33           |

## Security best practices

<Warning>
  Never expose your API key in client-side code, public repositories, or browser requests. Always call the API from your backend server.
</Warning>

* Store keys in environment variables, not in code
* Use different keys for development and production
* Rotate keys periodically
* Revoke unused keys from your dashboard
