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

# Authentication

> Authenticate with the Bonai News API using your API key

The Bonai News API authenticates every request with an API key. Keys are product-scoped: a Bonai News API key works only with the Bonai News API.

## Get an API key

1. Sign in to the [Bonai console](https://console.bonai.io).
2. Select the **Bonai News API** product workspace.
3. Open **API Keys** and create a new key.
4. Copy the key (`bk_...`). It is shown only once.

## Authenticate requests

Send your key in the `api-key` header on every request:

```bash theme={null}
curl --request GET \
  --url "https://api.bonai.io/news/search/articles?query=technology" \
  --header "api-key: YOUR_API_KEY"
```

### Other languages

```python theme={null}
import requests

resp = requests.get(
    "https://api.bonai.io/news/search/articles",
    params={"query": "technology"},
    headers={"api-key": "YOUR_API_KEY"},
)
print(resp.json())
```

```javascript theme={null}
const resp = await fetch(
  "https://api.bonai.io/news/search/articles?query=technology",
  { headers: { "api-key": "YOUR_API_KEY" } }
);
console.log(await resp.json());
```

## Public endpoints

The `GET /ping` endpoint is public and does not require an API key:

```bash theme={null}
curl --request GET \
  --url "https://api.bonai.io/news/ping"
```

## Managing keys

* **Revoke**: revoke a key from the API Keys page if it's compromised or no longer needed. Revocation is immediate.
* **Rotate**: create a new key, update your applications, then revoke the old one.

<Warning>
  Never share your API key or commit it to source control. Use environment variables or a secret manager in production.
</Warning>
