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

# Authentication

> Learn how to authenticate with the Kaspa Developer Platform API

## Overview

The Kaspa Developer Platform (KDP) API uses API keys to authenticate requests. You can get your API key by signing up at [developer.kas.fyi](https://developer.kas.fyi).

## Using Your API Key

Include your API key in the `x-api-key` header with each request:

```bash theme={null}
curl https://api.kas.fyi/addresses/kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz/tag \
  -H "x-api-key: YOUR_API_KEY"
```

<Warning>
  Keep your API key secure and never expose it in client-side code or public repositories.
</Warning>

## Example Usage

### JavaScript/TypeScript

```typescript theme={null}
const response = await fetch('https://api.kas.fyi/addresses/kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz/tag', {
  headers: {
    'x-api-key': 'YOUR_API_KEY'
  }
});

const data = await response.json();
```

### Python

```python theme={null}
import requests

headers = {
    'x-api-key': 'YOUR_API_KEY'
}

response = requests.get(
    'https://api.kas.fyi/addresses/kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz/tag',
    headers=headers
)

data = response.json()
```

### Go

```go theme={null}
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.kas.fyi/addresses/kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz/tag", nil)
req.Header.Add("x-api-key", "YOUR_API_KEY")

resp, _ := client.Do(req)
```

## Best Practices

1. **Store API keys securely**: Use environment variables or secure key management services
2. **Rotate keys regularly**: Generate new API keys periodically for better security
3. **Monitor usage**: Keep track of your API usage to avoid hitting rate limits
4. **Use HTTPS only**: Always make requests over HTTPS to protect your API key

## Error Handling

If your API key is missing or invalid, you'll receive a `401 Unauthorized` response:

```json theme={null}
{
  "statusCode": 401,
  "message": "x-api-key is missing from header"
}
```

or

```json theme={null}
{
  "statusCode": 401,
  "message": "Invalid API key"
}
```
