# Authentication

API keys are **optional** for public endpoints (`/v1/protocols`, `/v1/protocols/{id}`, `/v1/screener`, `/v1/stats`, `/v1/health`). Anonymous requests are rate-limited by IP. Pass `X-API-Key` to get higher rate limits and (later) tiered quotas. Wallet scanning (`/v1/wallet/{address}`) requires a Pro plan or higher.

### 2.1 API Key Header

```typescript
// Using raw fetch with the header
const res = await fetch("https://api.diapleo.xyz/v1/protocols", {
  headers: {
    "X-API-Key": process.env.DIAPLEO_API_KEY!,
    "Accept": "application/json",
  },
});
```

### 2.2 API Key Structure

| **Prefix**  | **Environment** | **Behavior**                                                                          |
| ----------- | --------------- | ------------------------------------------------------------------------------------- |
| dpk\_live\_ | Production      | Live protocol data, real usage meters, production rate limits                         |
| dpk\_test\_ | Sandbox         | Synthetic fixture data, no billing charges, same rate limits as production key's plan |

### 2.3 Security

API keys are shown only once at creation. If lost, revoke the key and generate a new one from your account dashboard.

Never embed API keys in client-side code, public repos, or CI logs. Use environment variables or a secrets manager.

Test keys (dpk\_test\_) return identical response shapes to production but with synthetic data. Build and test against test keys; switch to dpk\_live\_ only for production deployments.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.diapleo.com/api-reference/overview/authentication.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
