vaults.fyi
  • General
    • 🏦Overview
    • 💡Use Cases
      • For Wallets and Apps
        • Monetize Your Wallet Seamlessly & Securely
      • For Analysts
      • For Protocols & Product Teams
    • 🔎Methodology
      • vaults.fyi USD benchmark rate
      • vaults.fyi ETH benchmark rate
    • ❓FAQ
      • Vault requirements for inclusion on vaults.fyi
    • 🤖AI
  • API
    • Introduction
      • Market data
      • Transactional support
      • Portfolio tracking
      • Personalized insights
    • Quickstart
    • Tutorials
      • Wallet Integration
      • Data Analytics
    • SDK
  • Endpoints
    • General
    • Detailed Vaults
    • Historical
    • Portfolio
    • Transactions
    • Legacy (v1) endpoints
      • v1 Market data
        • Get historical data
          • Get historical APY and TVL data on single vault over timestamp range
          • Get historical APY on single vault over timestamp range
          • Get historical TVL on single vault at single timestamp
          • Get historical APY on single vault at single timestamp
        • Get data for multiple vaults
        • Get data on single vault
          • Get APY on single vault
        • Get benchmark rates
        • Get supported vaults, networks & tokens
          • /vaults
          • /networks
          • /tokens
          • /tags
      • v1 Contextual insights
        • Top vault options for address
        • Get single top option for address
        • [Etherscan cards] Get top USD, top ETH vault for address
      • v1 Generate payloads
        • Prepare calldata
          • Supply/Deposit
          • Withdraw/Redeem
            • Request redeem
            • Claim redeem
          • Claim rewards
        • Get contract interaction details
        • Get supported assets
        • Get supported vaults
      • v1 Position tracking
        • Get user balances
        • Get user positions
        • Get list of past vault txns by user address
        • Get estimated returns for user's vault position
  • Case Studies
    • Kraken Wallet
    • Etherscan Cards
    • Gauntlet
  • Plans
    • Credits
      • Credits (v1 endpoints)
  • Links
    • vaults.fyi
    • X
    • Farcaster
    • Wallfacer Labs
Powered by GitBook
On this page
  • Installation
  • API Methods
  1. API

SDK

Installation

For installation instructions use Quickstart

API Methods

Vault Methods

getAllVaults(params)

Get information about all available vaults.

const vaults = await sdk.getAllVaults({
  query: {
    networks: ['ethereum', 'polygon'],
    protocols: ['aave', 'compound'],
    limit: 100
  }
})

getVault(params)

Get detailed information about a specific vault.

const vault = await sdk.getVault({
  path: {
    network: 'ethereum',
    vaultAddress: '0x1234...'
  }
})

Historical Data Methods

getVaultHistoricalData(params)

Get historical APY and TVL data for a vault.

const historicalData = await sdk.getVaultHistoricalData({
  path: {
    network: 'ethereum',
    vaultAddress: '0x1234...'
  },
  query: {
    period: '30d',
    granularity: 'daily'
  }
})

Portfolio Methods

getPositions(params)

Get all positions for a user address.

const positions = await sdk.getPositions({
  path: {
    userAddress: '0x1234...'
  },
  query: {
    networks: ['ethereum', 'polygon']
  }
})

getDepositOptions(params)

Get the best deposit options for a user.

const options = await sdk.getDepositOptions({
  path: {
    userAddress: '0x1234...'
  },
  query: {
    amount: '1000',
    asset: 'USDC'
  }
})

getIdleAssets(params)

Get idle assets in a user's wallet that could be earning yield.

const idleAssets = await sdk.getIdleAssets({
  path: {
    userAddress: '0x1234...'
  }
})

getVaultTotalReturns(params)

Get total returns for a specific user and vault.

const returns = await sdk.getVaultTotalReturns({
  path: {
    userAddress: '0x1234...',
    network: 'ethereum',
    vaultAddress: '0x5678...'
  }
})

getVaultHolderEvents(params)

Get events (deposits, withdrawals) for a specific user and vault.

const events = await sdk.getVaultHolderEvents({
  path: {
    userAddress: '0x1234...',
    network: 'ethereum',
    vaultAddress: '0x5678...'
  }
})

Transaction Methods

getTransactionsContext(params)

Get transaction context for a specific vault interaction.

const context = await sdk.getTransactionsContext({
  path: {
    userAddress: '0x1234...',
    network: 'ethereum',
    vaultAddress: '0x5678...'
  }
})

getActions(params)

Get available actions (deposit, withdraw, etc.) for a vault.

const actions = await sdk.getActions({
  path: {
    action: 'deposit',
    userAddress: '0x1234...',
    network: 'ethereum',
    vaultAddress: '0x5678...'
  },
  query: {
    amount: '1000'
  }
})

Benchmark Methods

getBenchmarks()

Get benchmark data for comparing vault performance.

const benchmarks = await sdk.getBenchmarks()

Error Handling

The SDK throws HttpResponseError for API errors:

import { VaultsSdk, HttpResponseError } from 'vaultsfyi'

try {
  const vault = await sdk.getVault({
    path: {
      network: 'ethereum',
      vaultAddress: 'invalid-address'
    }
  })
} catch (error) {
  if (error instanceof HttpResponseError) {
    console.error('API Error:', error.message)
  }
}

Vault Methods

get_all_vaults(**kwargs)

Get information about all available vaults.

vaults = client.get_all_vaults(
    networks=['ethereum', 'polygon'],
    protocols=['aave', 'compound'],
    limit=100
)

get_vault(network, vault_address, **kwargs)

Get detailed information about a specific vault.

vault = client.get_vault(
    network='ethereum',
    vault_address='0x1234...'
)

Historical Data Methods

get_vault_historical_data(network, vault_address, **kwargs)

Get historical APY and TVL data for a vault.

historical_data = client.get_vault_historical_data(
    network='ethereum',
    vault_address='0x1234...',
    period='30d',
    granularity='daily'
)

Portfolio Methods

get_positions(user_address, **kwargs)

Get all positions for a user address.

positions = client.get_positions(
    user_address='0x1234...',
    networks=['ethereum', 'polygon']
)

get_deposit_options(user_address, allowed_assets=None, **kwargs)

Get the best deposit options for a user.

options = client.get_deposit_options(
    user_address='0x1234...',
    amount='1000',
    asset='USDC'
)

get_idle_assets(user_address, **kwargs)

Get idle assets in a user's wallet that could be earning yield.

idle_assets = client.get_idle_assets(
    user_address='0x1234...'
)

get_vault_total_returns(user_address, network, vault_address, **kwargs)

Get total returns for a specific user and vault.

returns = client.get_vault_total_returns(
    user_address='0x1234...',
    network='ethereum',
    vault_address='0x5678...'
)

get_vault_holder_events(user_address, network, vault_address, **kwargs)

Get events (deposits, withdrawals) for a specific user and vault.

events = client.get_vault_holder_events(
    user_address='0x1234...',
    network='ethereum',
    vault_address='0x5678...'
)

Transaction Methods

get_transactions_context(user_address, network, vault_address, **kwargs)

Get transaction context for a specific vault interaction.

context = client.get_transactions_context(
    user_address='0x1234...',
    network='ethereum',
    vault_address='0x5678...'
)

get_actions(action, user_address, network, vault_address, **kwargs)

Get available actions (deposit, withdraw, etc.) for a vault.

actions = client.get_actions(
    action='deposit',
    user_address='0x1234...',
    network='ethereum',
    vault_address='0x5678...',
    amount='1000'
)

Benchmark Methods

get_benchmarks()

Get benchmark data for comparing vault performance.

benchmarks = client.get_benchmarks()

Error Handling

The SDK provides specific exception types:

from vaultsfyi import VaultsSdk, HttpResponseError, AuthenticationError

try:
    client = VaultsSdk(api_key="invalid_key")
    result = client.get_benchmarks()
except AuthenticationError:
    print("Invalid API key")
except HttpResponseError as e:
    print(f"API error: {e}")
PreviousData AnalyticsNextEndpoints

Last updated 1 day ago