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

# Authentication

> Learn how to generate an API key on NGN Market.

Every request to the NGN Market API must include a valid API key in the `Authorization` header. The API validates the key on every request and returns an error immediately if it is missing, malformed, or revoked.

## Generate an API key

API keys are created and managed from your [developer dashboard](https://ngnmarket.com/developer).

1. Log in at [ngnmarket.com](https://ngnmarket.com)
2. Go to **Dashboard** → **Developer**
3. Click **Generate API key**, give it a name, and confirm
4. Copy the key immediately.

Your key will look like this:

```
ngm_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6
```

<Warning>
  Copy your key before leaving the page. If you lose it, revoke it and generate a new one.
</Warning>

## Attach the key to requests

Pass your key in the `Authorization` header using the Bearer scheme on every request:

```
Authorization: Bearer ngm_live_YOUR_KEY
```

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.ngnmarket.com/v1/market/snapshot \
    -H "Authorization: Bearer ngm_live_YOUR_KEY"
  ```

  ```javascript JavaScript theme={null}
  const res = await fetch('https://api.ngnmarket.com/v1/market/snapshot', {
    headers: { 'Authorization': 'Bearer ngm_live_YOUR_KEY' }
  });
  const data = await res.json();
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch('https://api.ngnmarket.com/v1/market/snapshot', {
    headers: { 'Authorization': 'Bearer ngm_live_YOUR_KEY' }
  });
  const data: Record<string, unknown> = await res.json();
  ```

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

  res = requests.get(
      'https://api.ngnmarket.com/v1/market/snapshot',
      headers={'Authorization': 'Bearer ngm_live_YOUR_KEY'}
  )
  print(res.json())
  ```
</CodeGroup>

## Managing your keys

From the [developer dashboard](https://ngnmarket.com/developer) you can:

* **View all keys**: see each key's name, creation date, and when it was last used
* **Create keys**: up to **5 active keys** per account. Give each key a name so you can identify which app or environment it belongs to
* **Revoke a key**: instantly invalidates the key. Any request using a revoked key immediately returns `INVALID_API_KEY`. Revoked keys are kept in the dashboard for your audit trail

<Tip>
  Create one key per app or environment (e.g. "Production", "Staging", "Local dev"). If a key is ever exposed, you can revoke just that one without affecting the others.
</Tip>

<Note>
  All keys on your account share a single monthly quota pool. Quota usage is tracked per account, not per key. See [Rate limits](/rate-limits) for details.
</Note>

## Authentication errors

| Error code        | Status | Cause                                                             |
| :---------------- | :----: | :---------------------------------------------------------------- |
| `MISSING_API_KEY` |   401  | `Authorization` header is missing or not in `Bearer <key>` format |
| `INVALID_API_KEY` |   401  | Key not found, already revoked, or does not start with `ngm_`     |

```json theme={null}
{
  "success": false,
  "error": {
    "code": "INVALID_API_KEY",
    "message": "API key not found or revoked."
  }
}
```
