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

# Authentication

> Learn how to authenticate with the Anysite API

## Overview

Anysite uses API key authentication to secure access to all endpoints. You'll need to include your API key in the request headers for all API calls.

## Getting Your API Key

<Steps>
  <Step title="Create Account">
    Visit [anysite.io](https://anysite.io) and create your account
  </Step>

  <Step title="Generate API Key">
    Navigate to your account settings and generate a new API key
  </Step>

  <Step title="Secure Storage">
    Store your API key securely and never expose it in client-side code
  </Step>
</Steps>

## Authentication Methods

### Access Token Header (Required)

Include your API key in the `access-token` header:

```bash theme={null}
curl -X GET "https://api.anysite.io/token/statistic" \
  -H "access-token: YOUR_API_KEY"
```

<Warning>
  The Anysite API does **not** use Bearer token authentication. Always use the `access-token` header.
</Warning>

## Rate Limits

API requests are subject to rate limiting to ensure fair usage:

<Note>
  Rate limits vary by endpoint and subscription plan. Check your dashboard for current limits.
</Note>

## Error Responses

When authentication fails, you'll receive one of these responses:

<ResponseField name="401 Unauthorized" type="error">
  Invalid or missing API key
</ResponseField>

<ResponseField name="403 Forbidden" type="error">
  API key doesn't have permission for this resource
</ResponseField>

<ResponseField name="429 Too Many Requests" type="error">
  Rate limit exceeded
</ResponseField>

## Best Practices

<Tip>
  * Store API keys as environment variables
  * Use different API keys for different environments
  * Rotate API keys regularly
  * Monitor API usage in your dashboard
  * Never commit API keys to version control
</Tip>

## Testing Authentication

Test your authentication setup with this simple request:

<CodeGroup>
  ```bash cURL theme={null}
  curl -X GET "https://api.anysite.io/token/statistic" \
    -H "access-token: YOUR_API_KEY"
  ```

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

  headers = {
      'access-token': 'YOUR_API_KEY'
  }

  response = requests.get(
      'https://api.anysite.io/token/statistic',
      headers=headers
  )

  print(response.json())
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.anysite.io/token/statistic', {
    headers: {
      'access-token': 'YOUR_API_KEY'
    }
  });

  const data = await response.json();
  console.log(data);
  ```
</CodeGroup>
