# API Endpoints

### 1.1 TypeScript-First Design

All request and response shapes are defined as TypeScript interfaces in the `@diapleo/sdk` package and in the OpenAPI 3.0 spec. Engineers consuming the API in TypeScript have full autocomplete and type safety without additional codegen.

```typescript
// Install the official SDK (coming soon)
npm install @diapleo/sdk
```

### 1.2 Base URL & Versioning

```typescript
const BASE_URL = "https://api.diapleo.xyz/v1";
```

All endpoints live under `/v1`. New endpoints and new non-breaking response fields ship within `/v1`. Breaking changes ship under a future `/v2`.

### 1.3 Response Envelopes

Every response is JSON and follows one of three envelopes.

```typescript
// Single resource — GET /v1/protocols/{id}, GET /v1/stats
interface SingleResponse<T> {
  success: true;
  data: T;
}

// Paginated list — GET /v1/protocols, GET /v1/screener
interface PaginatedResponse<T> {
  success: true;
  data: T[];
  meta: {
    total: number;
    page: number;
    limit: number;
    pageCount: number;
  };
}

// Error — any 4xx/5xx
interface ErrorResponse {
  success: false;
  data: null;
  error: {
    code: string;
    message: string;
    status: number;
    details?: Record<string, string[]>;
  };
}
```

### 1.4 Conventions

* **Field naming:** `camelCase` throughout.
* **Dates:** ISO 8601 strings (`"2026-04-21T11:58:35.516Z"`).
* **Scores:** 0–10 scale, lower = safer. `null` when not applicable (a dimension can be `null` if the protocol has no relevant signal).
* **Risk levels:** `"very-low" | "low" | "moderate" | "elevated" | "high"`. See [Data Types & Enums](/api-reference/overview/data-types-and-enums.md) for score-to-level mapping.
* **Auth:** Optional on public endpoints, required on `/v1/wallet/{address}`. See [Authentication](/api-reference/overview/authentication.md).
* **Rate limits:** Headers on every response. See [Rate Limits](/api-reference/overview/rate-limits.md).

### 1.5 Endpoint Overview

| **Endpoint**           | **Method** | **Auth** | **Purpose**                                                                            |
| ---------------------- | ---------- | -------- | -------------------------------------------------------------------------------------- |
| `/v1/health`           | GET        | none     | Health check                                                                           |
| `/v1/stats`            | GET        | optional | Ecosystem aggregates (protocol count, global risk, TVL)                                |
| `/v1/protocols`        | GET        | optional | Paginated, filterable protocol list                                                    |
| `/v1/protocols/{id}`   | GET        | optional | Full protocol detail (dimensions, chainTvls, similar, incidents, scoreHistory, audits) |
| `/v1/screener`         | GET        | optional | Same as `/protocols` plus per-dimension `max*` filters and dimension scores inline     |
| `/v1/wallet/{address}` | GET        | **Pro+** | Scan wallet for DeFi positions and portfolio risk. Accepts EVM, Solana, ENS, SNS       |
| `/v1/usage`            | GET        | required | Usage report for your key                                                              |


---

# 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/api-endpoints.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.
