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

# Get Vault APYs

> Fetch vault APY data using the API or SDK

## How Vault APY Is Calculated

Vault APY is a blended rate based on the reserves the vault's capital is deployed across.

```
Vault APY ≈ Σ (Reserve APY × Allocation Weight)
```

Each reserve earns yield based on its utilization and borrow rate. A reserve at 80% utilization earning 8% APY contributes to the vault's total yield based on its allocation weight, the share of capital deployed there. Allocation weights sum to 100% across all active reserves.

**Example — a USDC vault with two allocations:**

| Reserve          | Allocation | APY |
| ---------------- | ---------- | --- |
| USDC Main Market | 60%        | 8%  |
| USDC JLP Market  | 40%        | 12% |

```
Blended APY = (60% × 8%) + (40% × 12%) = 9.6%
```

Underlying borrow rates and utilization levels change continuously, so vault APY fluctuates. Quoted APYs are trailing averages and are not guaranteed forward-looking rates.

The displayed APY includes base interest from borrowers plus KMNO emissions when active. APY accounts for compounding. In Kamino vaults, earnings are continuously reinvested, increasing the vault share price over time.

<Tabs>
  <Tab title="API">
    <Steps>
      <Step>
        ### Fetch All Vaults

        Retrieve the list of all available vaults on Kamino.

        ```typescript theme={null}
        const API_BASE_URL = 'https://api.kamino.finance';
        const response = await fetch(`${API_BASE_URL}/kvaults/vaults`);
        const vaults = await response.json();
        ```

        <Info>
          The `/kvaults/vaults` endpoint returns all vaults with basic information including vault addresses, token mints, and strategies.
        </Info>
      </Step>

      <Step>
        ### Get APY for Each Vault

        Fetch APY metrics for all vaults in parallel using the vault public keys.

        ```typescript theme={null}
        // Fetch all vault metrics in parallel
        const vaultMetrics = await Promise.all(
          vaults.map(async (vault) => {
            const response = await fetch(
              `${API_BASE_URL}/kvaults/vaults/${vault.address}/metrics`
            );
            const metrics = await response.json();

            return {
              address: vault.address,
              apy7d: metrics.apy7d,
              apy30d: metrics.apy30d,
              apy90d: metrics.apy90d,
            };
          })
        );

        // Display all vault APYs
        vaultMetrics.forEach((vault) => {
          console.log(`\n${vault.address}:`);
          console.log(`  7-day APY: ${(vault.apy7d * 100).toFixed(2)}%`);
          console.log(`  30-day APY: ${(vault.apy30d * 100).toFixed(2)}%`);
          console.log(`  90-day APY: ${(vault.apy90d * 100).toFixed(2)}%`);
        });
        ```

        <Info>
          The `/kvaults/vaults/{pubkey}/metrics` endpoint returns historical APY data across multiple timeframes (7-day, 24-hour, 30-day, 90-day, 180-day, 365-day).
        </Info>

        <Check>
          You now have APY data for all vaults across multiple timeframes.
        </Check>
      </Step>
    </Steps>
  </Tab>

  <Tab title="SDK">
    <Steps>
      <Step>
        ### Import Dependencies

        Import the required packages for Solana RPC communication and Kamino SDK.

        ```typescript theme={null}
        import { createSolanaRpc } from '@solana/kit';
        import { KaminoManager, KaminoVault } from '@kamino-finance/klend-sdk';
        ```
      </Step>

      <Step>
        ### Initialize SDK

        Set up the RPC connection and create a Kamino Manager instance.

        ```typescript theme={null}
        const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
        const kaminoManager = new KaminoManager(rpc, 400);
        ```
      </Step>

      <Step>
        ### Get All Vaults

        Retrieve all available vaults using the Kamino Manager.

        ```typescript theme={null}
        const vaults = await kaminoManager.getAllVaults();
        ```
      </Step>

      <Step>
        ### Get APYs for Each Vault

        Fetch APY data for all vaults in parallel.

        ```typescript theme={null}
        // Fetch APYs for all vaults in parallel
        const vaultAPYs = await Promise.all(
          vaults.map(async (vaultData) => {
            const vault = new KaminoVault(rpc, vaultData.address);
            const apys = await vault.getAPYs();

            return {
              address: vaultData.address.toString(),
              name: vaultData.state?.name,
              actualAPY: apys.actualAPY.netAPY,
              theoreticalAPY: apys.theoreticalAPY.netAPY,
            };
          })
        );

        // Display all vault APYs
        vaultAPYs.forEach((vault) => {
          console.log(`\n${vault.address}:`);
          console.log(`  Actual APY: ${vault.actualAPY}`);
          console.log(`  Theoretical APY: ${vault.theoreticalAPY}`);
        });
        ```

        <Info>
          The `vault.getAPYs()` method returns `theoreticalAPY` and `actualAPY`, each containing `grossAPY` and `netAPY` (after fees) calculated from on-chain state.
        </Info>

        <Check>
          You've successfully fetched vault APYs using the Kamino SDK.
        </Check>
      </Step>
    </Steps>
  </Tab>
</Tabs>

## Related Resources

<CardGroup cols={2}>
  <Card title="Lending Vaults Concepts" icon="book" href="/products/lending-vaults/concepts">
    Learn how vaults work under the hood
  </Card>

  <Card title="Vault Data" icon="database" href="/build/earn/vault-data-positions">
    Query vault metrics and positions
  </Card>

  <Card title="Benchmark Rate" icon="chart-line" href="/products/lending-vaults/benchmark-rate">
    Compare vault yields to market baseline
  </Card>

  <Card title="Earn Deposit" icon="arrow-down" href="/build/recipes/earn/earn-via-api">
    Deposit into vaults via API
  </Card>
</CardGroup>
