# API Reference

The YieldFi SDK provides several API modules for interacting with different YieldFi services. This section covers all available APIs.

### Available APIs

#### Vault API

Query vault information, protocol statistics, whitelisted assets, and transaction history.

**Key Features:**

* Protocol statistics and metrics
* Vault listings and details
* Whitelisted asset management
* Transaction history with role-based filtering

#### Glassbook API

Manage partner transactions (PTX) and referrals.

**Key Features:**

* Create and query partner transactions
* Referral code management
* Referral statistics and tracking

### Authentication

Most APIs require authentication. See the Authentication Guide for details.

**Public APIs** (no authentication required):

* `sdk.vault.getProtocolStats()`
* `sdk.vault.getStrategies()`
* `sdk.vault.getVaults()`
* `sdk.vault.getVaultByKey()`
* `sdk.vault.getVaultBySymbol()`
* `sdk.vault.getVaultDetails()`
* `sdk.vault.getVaultFaqs()`
* `sdk.vault.getWhitelistedAssets()`
* `sdk.vault.getWhitelistedAsset()`
* `sdk.vault.checkAssetWhitelisted()`

**Protected APIs** (authentication required):

* All transaction endpoints
* All Glassbook endpoints
* All Forms endpoints
* All Curator Handoff endpoints
* Private vault access
* Admin operations (whitelist management, etc.)

### Common Patterns

#### Pagination

Many APIs support pagination:

```typescript
const result = await sdk.vault.getVaults({
  page: 1,
  pageSize: 20,
});

console.log(`Page ${result.pagination.page} of ${result.pagination.totalPages}`);
console.log(`Total: ${result.pagination.total}`);
```

#### Filtering

APIs support various filters:

```typescript
const transactions = await sdk.vault.getTransactions(
  {
    chainId: 1,
    type: "deposit",
    status: "PROCESSED",
    startDate: "2024-01-01T00:00:00.000Z",
    endDate: "2024-01-31T23:59:59.999Z",
  },
  accessToken
);
```

#### Error Handling

Always handle errors:

```typescript
import {
  AuthenticationError,
  NetworkError,
  ValidationError,
} from "yieldfi-sdk";

try {
  const vault = await sdk.vault.getVaultByKey("yusd", 1);
} catch (error) {
  if (error instanceof AuthenticationError) {
    // Handle auth errors
  } else if (error instanceof NetworkError) {
    // Handle network errors
  } else if (error instanceof ValidationError) {
    // Handle validation errors
  }
}
```

### Next Steps

* Vault API - Query vaults and transactions
* Glassbook API - Partner transactions and referrals


---

# 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.yield.fi/earn-with-yieldfi/integration-sdk/api-reference.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.
