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

# Authentication

> How to authenticate your API requests

## API Key Authentication

All API requests require an API key passed via the `X-API-Key` header.

```bash theme={null}
curl -H "X-API-Key: tn_live_your_key_here" \
  "https://api.tradingnews.press/v1/news"
```

## Getting Your API Key

1. Sign up at [tradingnews.press](https://tradingnews.press)
2. Go to [Dashboard > API Keys](https://tradingnews.press/dashboard/keys)
3. Click **Create Key**
4. Copy the key immediately — it's only shown once

## Key Format

TradingNews API keys use a prefix format for easy identification:

| Prefix     | Environment           |
| ---------- | --------------------- |
| `tn_live_` | Production            |
| `tn_test_` | Sandbox (coming soon) |

## Security Best Practices

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

* Store keys in environment variables, not in code
* Use different keys for different applications
* Revoke and rotate keys if you suspect exposure
* Each key has independent rate limits and usage tracking

## Error Responses

| Status | Meaning                           |
| ------ | --------------------------------- |
| `401`  | Invalid or missing API key        |
| `403`  | Key is inactive or access blocked |
| `429`  | Rate limit exceeded               |

```json theme={null}
// 401 — Invalid key
{ "detail": "Invalid API key" }

// 403 — Inactive key
{ "detail": "API key is inactive" }

// 429 — Rate limited
{ "detail": "Rate limit exceeded. Try again shortly." }
```
