> ## 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.

# Market Data and Metrics

> Learn how to access market data including supply APY, borrow APY, TVL, and utilization rates for lending reserves

## Get Market Information

Retrieve market-wide TVL metrics for deposits and borrows.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    import { createSolanaRpc, address } from '@solana/kit';
    import { KaminoMarket } from '@kamino-finance/klend-sdk';

    const slotDuration = 400; // ms
    const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
    const marketPubkey = address('7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF');

    const market = await KaminoMarket.load(rpc, marketPubkey, slotDuration);

    console.log({
    deposits: market!.getTotalDepositTVL(),
    borrows: market!.getTotalBorrowTVL(),
    });

    ```

    <a target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>

## Get Reserve Supply and Borrow APY

Fetch historical supply APY and borrow APY data for a specific reserve over time.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const API_BASE_URL = 'https://api.kamino.finance';
    const marketPubkey = '7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF';
    const reservePubkey = '37Jk2zkz23vkAYBT66HM2gaqJuNg2nYLsCreQAVt5MWK';

    const url = `${API_BASE_URL}/kamino-market/${marketPubkey}/reserves/${reservePubkey}/metrics/history`;

    const res = await fetch(url);

    if (!res.ok) {
    throw new Error(`Request failed: ${res.status} ${res.statusText}`);
    }

    const data = await res.json();

    for (const item of data.history) {
    console.log({
      timestamp: item.timestamp,
      supplyInterestAPY: item.metrics.supplyInterestAPY,
      borrowInterestAPY: item.metrics.borrowInterestAPY,
      depositTvl: item.metrics.depositTvl,
      borrowTvl: item.metrics.borrowTvl,
    });
    }
    ```

    <a target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>

## Get Reserve Information

Check detailed metrics for all reserves including supply APY, borrow APY, deposit TVL, borrow TVL, and utilization rates.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    import { createSolanaRpc, address } from '@solana/kit';
    import { KaminoMarket } from '@kamino-finance/klend-sdk';

    const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
    const marketPubkey = address('DxXdAyU3kCjnyggvHmY5nAwg5cRbbmdyX3npfDMjjMek');

    const slotDuration = 400; // ms
    const slot = await rpc.getSlot().send();

    const market = await KaminoMarket.load(rpc, marketPubkey, slotDuration);

    for (const reserve of market!.getReserves()) {
      console.log(`Reserve ${reserve.symbol}:`);
      console.log(`  Deposit TVL: ${reserve.getDepositTvl().toFixed(2)}`);
      console.log(`  Borrow TVL: ${reserve.getBorrowTvl().toFixed(2)}`);
      console.log(`  Borrow APY: ${reserve.totalBorrowAPY(slot)}%`);
      console.log(`  Supply APY: ${reserve.totalSupplyAPY(slot)}%`);
      console.log(`  Utilization: ${reserve.calculateUtilizationRatio()}%`);
    }
    ```

    <a target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>

## Get Reserve Reward History

Fetches historical KLend reward metrics for a specific deposit and borrow reserve pair.

<Note>
  This endpoint returns KMNO reward incentives for specific deposit and borrow reserve combinations.
</Note>

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const depositReservePubkey = 'd4A2prbA2whesmvHaL88BH6Ewn5N4bTSU2Ze8P6Bc4Q';
    const borrowReservePubkey = 'D6q6wuQSrifJKZYpR1M8R4YawnLDtDsMmWM1NbBmgJ59';

    const API_BASE_URL = 'https://api.kamino.finance';

    const params = new URLSearchParams({
    start: '2025-11-07T00:00:00.000Z',
    end: '2025-11-14T23:59:59.999Z',
    frequency: 'day',
    }).toString();

    const url = `${API_BASE_URL}/klend/${depositReservePubkey}/${borrowReservePubkey}/rewards/history?${params}`;
    const res = await fetch(url);
    if (!res.ok) {
    throw new Error(`Request failed: ${res.status} ${res.statusText}`);
    }
    const data = await res.json();
    console.log(data);
    ```

    <a target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>

## Get User Obligation Info

Retrieve detailed obligation information including deposits, borrows, and health metrics.

<Tabs>
  <Tab title="TypeScript">
    ```typescript expandable theme={null}
    import { createSolanaRpc, address } from '@solana/kit';
    import { KaminoMarket, VanillaObligation, PROGRAM_ID } from '@kamino-finance/klend-sdk';

    const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
    const marketPubkey = address('7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF');
    const userAddress = address('EZC9wzVCvihCsCHEMGADYdsRhcpdRYWzSCZAVegSCfqY');

    const market = await KaminoMarket.load(rpc, marketPubkey, 400, PROGRAM_ID);

    const kaminoObligation = await market!.getObligationByWallet(
      userAddress,
      new VanillaObligation(PROGRAM_ID)
    );

    if (!kaminoObligation) {
      console.log('No obligation found for user:', userAddress);
    } else {
      console.log('Obligation Info:');
      console.log('Owner:', kaminoObligation.state.owner.toString());

      console.log('\nDeposits (Collateral):');
      const deposits = [...kaminoObligation.deposits.values()];
      deposits.forEach((deposit) => {
        console.log(`Reserve:`, deposit.reserveAddress.toString());
        console.log(`    Amount:`, deposit.amount);
        console.log(`    Market Value:`, deposit.marketValueRefreshed);
      });

      console.log('\nBorrows:');
      const borrows = [...kaminoObligation.borrows.values()];
      borrows.forEach((borrow) => {
        console.log(`Reserve:`, borrow.reserveAddress.toString());
        console.log(`    Amount:`, borrow.amount);
      });

      console.log('\nMetrics:');
      console.log('Loan-to-Value:', kaminoObligation.loanToValue());
      console.log('Borrow Utilization:', kaminoObligation.refreshedStats.borrowUtilization);
      console.log('Number of Positions:', kaminoObligation.getNumberOfPositions());
    }
    ```

    <a target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>

## Get All User Obligations

Retrieve all obligations for a user wallet, including different obligation types across the market.

<Tabs>
  <Tab title="TypeScript">
    ```typescript expandable theme={null}
    import { createSolanaRpc, address } from '@solana/kit';
    import { KaminoMarket, PROGRAM_ID, ObligationTypeTag } from '@kamino-finance/klend-sdk';

    const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
    const marketPubkey = address('7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF');
    const userWallet = address('Hs9ioQZ2pCUyvS18anwmBxjQJsZrMPShwTMLySD6Us3V');

    const market = await KaminoMarket.load(rpc, marketPubkey, 400, PROGRAM_ID);

    const obligations = await market.getAllUserObligations(userWallet);

    if (obligations.length === 0) {
    console.log('No obligations found for wallet:', userWallet);
    } else {
    console.log(`Found ${obligations.length} obligation(s):\n`);

    obligations.forEach((obligation, i) => {
      console.log(`Obligation ${i + 1}:`);
      console.log('Address:', obligation.obligationAddress.toString());
      console.log('Type:', ObligationTypeTag[obligation.obligationTag]);
      console.log('Owner:', obligation.state.owner.toString());

      console.log('\nDeposits (Collateral):');
      const deposits = [...obligation.deposits.values()];
      deposits.forEach((deposit) => {
        console.log(`  Reserve:`, deposit.reserveAddress.toString());
        console.log(`    Amount:`, deposit.amount);
        console.log(`    Market Value:`, deposit.marketValueRefreshed);
      });

      console.log('\nBorrows:');
      const borrows = [...obligation.borrows.values()];
      borrows.forEach((borrow) => {
        console.log(`  Reserve:`, borrow.reserveAddress.toString());
        console.log(`    Amount:`, borrow.amount);
        console.log(`    Market Value:`, borrow.marketValueRefreshed);
      });

      console.log('\nMetrics:');
      console.log('Loan-to-Value:', obligation.loanToValue());
      console.log('Borrow Utilization:', obligation.refreshedStats.borrowUtilization);
      console.log('Number of Positions:', obligation.getNumberOfPositions());
    });
    }
    ```

    <a target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>

## Get All Obligations by Reserve

Retrieve all obligations that have deposits in a specific reserve. Useful for analyzing reserve utilization and user exposure.

<Tabs>
  <Tab title="TypeScript">
    ```typescript expandable theme={null}
    import { createSolanaRpc, address } from '@solana/kit';
    import { KaminoMarket, PROGRAM_ID, ObligationTypeTag } from '@kamino-finance/klend-sdk';

    // Note: This example requires a paid/dedicated RPC node. Public RPCs will hit rate limits.
    const rpc = createSolanaRpc('https://api.mainnet-beta.solana.com');
    const marketPubkey = address('7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF');
    const reserveAddress = address('37Jk2zkz23vkAYBT66HM2gaqJuNg2nYLsCreQAVt5MWK');

    const market = await KaminoMarket.load(rpc, marketPubkey, 400, PROGRAM_ID);

    const obligations = await market.getAllObligationsByDepositedReserve(reserveAddress);

    if (obligations.length === 0) {
    console.log('No obligations found with deposits in reserve:', reserveAddress);
    } else {
    console.log(`Found ${obligations.length} obligation(s) with deposits in this reserve:\n`);

    obligations.forEach((obligation, i) => {
      console.log(`Obligation ${i + 1}:`);
      console.log('Address:', obligation.obligationAddress.toString());
      console.log('Type:', ObligationTypeTag[obligation.obligationTag]);
      console.log('Owner:', obligation.state.owner.toString());

      const reserveDeposit = [...obligation.deposits.values()].find(
        (deposit) => deposit.reserveAddress.toString() === reserveAddress.toString()
      );

      if (reserveDeposit) {
        console.log('\nDeposit in this Reserve:');
        console.log('  Amount:', reserveDeposit.amount);
        console.log('  Market Value:', reserveDeposit.marketValueRefreshed);
      }

      const otherDeposits = [...obligation.deposits.values()].filter(
        (deposit) => deposit.reserveAddress.toString() !== reserveAddress.toString()
      );
      if (otherDeposits.length > 0) {
        console.log('\nOther Deposits:');
        otherDeposits.forEach((deposit) => {
          console.log('  Reserve:', deposit.reserveAddress.toString());
          console.log('    Market Value:', deposit.marketValueRefreshed);
        });
      }

      const borrows = [...obligation.borrows.values()];
      if (borrows.length > 0) {
        console.log('\nBorrows:');
        borrows.forEach((borrow) => {
          console.log('  Reserve:', borrow.reserveAddress.toString());
          console.log('    Market Value:', borrow.marketValueRefreshed);
        });
      }

      console.log('\nMetrics:');
      console.log('Loan-to-Value:', obligation.loanToValue());
      console.log('Number of Positions:', obligation.getNumberOfPositions());
      console.log();
    });
    }
    ```

    <a target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>

## Get User Transaction History

Access all transaction history for a user's wallet across deposits, borrows, repayments, and liquidations.

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    const marketPubkey = 'DxXdAyU3kCjnyggvHmY5nAwg5cRbbmdyX3npfDMjjMek';
    const userPubkey = 'EZC9wzVCvihCsCHEMGADYdsRhcpdRYWzSCZAVegSCfqY';

    const API_BASE_URL = 'https://api.kamino.finance';

    const url = `${API_BASE_URL}/v2/kamino-market/${marketPubkey}/users/${userPubkey}/transactions`;

    const res = await fetch(url);

    if (!res.ok) {
    throw new Error(`Request failed: ${res.status} ${res.statusText}`);
    }

    const data = await res.json();

    console.log(data);
    ```

    <a target="_blank" rel="noopener noreferrer" class="github-link">
      <Icon icon="github" iconType="brands" size={16} />

      <span>View Code</span>
    </a>
  </Tab>
</Tabs>
