# Napier API

The **Napier API** is the data infrastructure layer of the Napier Protocol ecosystem. It aggregates, processes, and serves data from both on-chain and off-chain sources to support market analytics, token information, and integrated services.

{% embed url="<https://api-dev.napier.finance/docs>" %}

#### Core Functions

* **Data Aggregation:** Combines information from subgraphs, RPCs, and off-chain sources.
* **Caching & Snapshots:** Uses Redis caching and periodic snapshots for faster queries and historical analysis.
* **Multi-Chain Queries:** Provides a unified interface to query data across multiple blockchains.
* **Off-Chain Storage:** Manages persistent application data and metadata using PostgreSQL and AWS S3.
* **Subgraph Proxying:** Enhances subgraph queries with additional metadata and fallback mechanisms.
* **Administrative Tools:** Supports Slack bot operations, curator management, and reward point systems.

#### Infrastructure

* **Authentication:** SIWE (Sign-In with Ethereum) using JWT.
* **Storage & Database:** PostgreSQL with TypeORM and AWS S3.
* **Monitoring:** Health checks, Sentry integration, and alerting tools.
* **Performance:** Redis caching, query optimization, and rate limiting.

#### Developer Experience

* Auto-generated Swagger/OpenAPI documentation.
* Multi-environment support (development, staging, production).
* Migration tools and schema versioning.
* Comprehensive test and build scripts.

#### Technology Stack

NestJS (TypeScript), PostgreSQL, Redis, JWT (SIWE), AWS S3, Viem (Ethereum), Sentry, Swagger/OpenAPI.

#### Authentication Endpoints

* **Initialize SIWE:** `POST /v1/auth/siwe/init`
* **Sign In:** `POST /v1/auth/siwe/signin`
* **Get Profile:** `GET /v1/auth/me`

#### Core Endpoints

* **Markets:** `/v1/market/*` — Yield tokenization data and analytics
* **Users:** `/v1/user/*` — Portfolio and account data
* **Points:** `/v1/point/*` — Reward system
* **Curators:** `/v1/curator/*` — Curator operations
* **Tokens:** `/v1/token/*` — Token metadata
* **Health:** `/v1/health` — System status

#### Security

* Authenticated endpoints with SIWE/JWT
* Input validation and SQL injection prevention
* Rate limiting and caching against abuse
* Secure file uploads via pre-signed URLs

#### Getting Started

1. Clone the repo and install dependencies with `pnpm install`.
2. Configure environment variables (`.env`).
3. Start PostgreSQL and Redis (`docker-compose up -d`).
4. Run migrations: `pnpm run migration:run`.
5. Start the server: `pnpm run start:dev`.\
   API available at `http://localhost:3000` with docs at `/docs`.


---

# Agent Instructions: 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.napier.finance/build/developer-guide/napier-api.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.
