Skip to main content
This quickstart walks you through the core Earn flows: discovering vaults via the Earn Data API, checking a user’s positions, and then executing a deposit via Composer.

Prerequisites

  • curl or Node.js 18+ (for fetch)
  • An API key from the LI.FI Partner Portal, passed via the x-lifi-api-key header
  • No wallet is needed for data calls (steps 1 to 4). A wallet is only required for deposits (step 5).

1. List Available Vaults

Fetch vaults sorted by APY, filtered to a specific chain:
curl -X GET 'https://earn.li.fi/v1/earn/vaults?\
chainId=8453&\
sortBy=apy&\
limit=5' \
  --header 'x-lifi-api-key: YOUR_API_KEY'
The response includes an array of NormalizedVault objects with full metadata, analytics, and transactional capabilities.

2. Get a Single Vault

Fetch full details for a specific vault by chain ID and contract address:
curl -X GET 'https://earn.li.fi/v1/earn/vaults/8453/0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A' \
  --header 'x-lifi-api-key: YOUR_API_KEY'
Use GET /v1/earn/chains and GET /v1/earn/protocols to build dynamic filter UIs showing only the chains and protocols that currently have vaults. Both endpoints return lightweight lists and can be fetched once per session.

3. Check a User’s Positions

Look up a user’s DeFi positions across all supported protocols:
curl -X GET 'https://earn.li.fi/v1/earn/portfolio/0xYOUR_WALLET_ADDRESS/positions' \
  --header 'x-lifi-api-key: YOUR_API_KEY'
Example response:
{
  "positions": [
    {
      "chainId": 1,
      "protocolName": "aave-v3",
      "asset": {
        "address": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
        "name": "USD Coin",
        "symbol": "USDC",
        "decimals": 6
      },
      "balanceUsd": "1523.45",
      "balanceNative": "1523450000"
    }
  ]
}

4. Deposit via Composer

Once you’ve found a vault, use its contract address as the toToken with Composer to execute a deposit. Composer handles the swap, bridge (if cross-chain), and deposit in a single transaction.
# Deposit 1 USDC into a Morpho vault on Base
curl -X GET 'https://li.quest/v1/quote?\
fromChain=8453&\
toChain=8453&\
fromToken=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913&\
toToken=0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A&\
fromAddress=0xYOUR_WALLET_ADDRESS&\
toAddress=0xYOUR_WALLET_ADDRESS&\
fromAmount=1000000'
The deposit step uses Composer (li.quest), not the Earn Data API. See the Composer API Integration Guide for full details on executing transactions.

Next Steps

API Integration Guide

Full endpoint reference with all parameters and response examples

Discover and Deposit Recipe

End-to-end recipe: find the best vault for a token, then deposit