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

# Quickstart

> Get started with LI.FI Earn in under 5 minutes. List vaults, get vault details, check user positions, and deposit via Composer.

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](https://li.fi/plans/), 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:

<CodeGroup>
  ```bash curl theme={"system"}
  curl -X GET 'https://earn.li.fi/v1/vaults?chainId=8453&sortBy=apy&limit=5' \
    --header 'x-lifi-api-key: YOUR_API_KEY'
  ```

  ```ts TypeScript theme={"system"}
  const response = await fetch(
    'https://earn.li.fi/v1/vaults?chainId=8453&sortBy=apy&limit=5',
    { headers: { 'x-lifi-api-key': 'YOUR_API_KEY' } }
  );
  const { data, nextCursor, total } = await response.json();

  console.log(`Found ${total} vaults on Base`);
  data.forEach((vault) => {
    console.log(`${vault.name}: ${(vault.analytics.apy.total * 100).toFixed(2)}% APY`);
  });
  ```
</CodeGroup>

The response includes an array of [NormalizedVault](/earn/how-it-works#the-normalizedvault-schema) 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:

<CodeGroup>
  ```bash curl theme={"system"}
  curl -X GET 'https://earn.li.fi/v1/vaults/8453/0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A' \
    --header 'x-lifi-api-key: YOUR_API_KEY'
  ```

  ```ts TypeScript theme={"system"}
  const response = await fetch(
    'https://earn.li.fi/v1/vaults/8453/0x7BfA7C4f149E7415b73bdeDfe609237e29CBF34A'
  );
  const vault = await response.json();

  console.log(`${vault.name} on ${vault.network}`);
  console.log(`APY: ${(vault.analytics.apy.total * 100).toFixed(2)}%`);
  console.log(`TVL: $${vault.analytics.tvl.usd}`);
  console.log(`Depositable: ${vault.isTransactional}`);
  ```
</CodeGroup>

<Tip>
  Use `GET /v1/chains` and `GET /v1/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.
</Tip>

***

## 3. Check a User's Positions

Look up a user's DeFi positions across all supported protocols:

<CodeGroup>
  ```bash curl theme={"system"}
  curl -X GET 'https://earn.li.fi/v1/portfolio/0xYOUR_WALLET_ADDRESS/positions' \
    --header 'x-lifi-api-key: YOUR_API_KEY'
  ```

  ```ts TypeScript theme={"system"}
  const response = await fetch(
    'https://earn.li.fi/v1/portfolio/0xYOUR_WALLET_ADDRESS/positions'
  );
  const { positions } = await response.json();

  positions.forEach((pos) => {
    console.log(`${pos.asset.symbol} on ${pos.protocolName}: $${pos.balanceUsd}`);
  });
  ```
</CodeGroup>

Example response:

```json theme={"system"}
{
  "positions": [
    {
      "chainId": 1,
      "address": "0xa17581a9e3356d9a858b789d68b4d866e593ae94",
      "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](/composer/overview) to execute a deposit. Composer handles the swap, bridge (if cross-chain), and deposit in a single transaction.

<CodeGroup>
  ```bash curl theme={"system"}
  # 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'
  ```

  ```ts TypeScript theme={"system"}
  // Use the vault's contract address as toToken
  const vault = data[0]; // from step 1

  const quote = await fetch(
    `https://li.quest/v1/quote?` +
    `fromChain=${vault.chainId}` +
    `&toChain=${vault.chainId}` +
    `&fromToken=0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913` + // USDC on Base
    `&toToken=${vault.address}` +
    `&fromAddress=0xYOUR_WALLET_ADDRESS` +
    `&toAddress=0xYOUR_WALLET_ADDRESS` +
    `&fromAmount=1000000` // 1 USDC
  ).then((r) => r.json());

  // quote.transactionRequest is ready to sign and send
  console.log('Transaction:', quote.transactionRequest);
  ```
</CodeGroup>

<Note>
  The deposit step uses **Composer** (`li.quest`), not the Earn Data API. See the [Composer API Integration Guide](/composer/guides/api-integration) for full details on executing transactions.
</Note>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="API Integration Guide" icon="code" href="/earn/guides/api-integration">
    Full endpoint reference with all parameters and response examples
  </Card>

  <Card title="Discover and Deposit Recipe" icon="book" href="/earn/recipes/discover-and-deposit">
    End-to-end recipe: find the best vault for a token, then deposit
  </Card>
</CardGroup>
