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

# API vs SDK

> Choose between the REST API and SDKs for data and transactions.

Access data and build transactions through the API. Use the Read SDK for on-chain data and the Lend SDK for transaction building.

## Overview

Jupiter Lend provides multiple integration options:

| Option | Description |
| - | - |
| **REST API** | HTTPS endpoints for data, positions, earnings, and unsigned transactions. Language-agnostic. |
| **Read SDK** (`@jup-ag/lend-read`) | On-chain reads for Earn and Borrow. Lending tokens, token details, user positions, vaults, and vault positions. TypeScript only. |
| **Lend SDK** (`@jup-ag/lend`) | Instruction builders for deposit, withdraw, mint, redeem, and transaction flows. TypeScript only. |

## Core differences

| Capability | REST API | Read SDK | Lend SDK |
| - | - | - | - |
| Earn tokens and pool details | `tokens` endpoint | `getAllJlTokens`, `getJlTokenDetails`, `getAllJlTokenDetails` | - |
| Earn user positions | `positions` endpoint | `getUserPosition`, `getUserPositions` | - |
| Earnings data | `earnings` endpoint | - | - |
| Vault config and state | - | `getAllVaults`, `getVaultByVaultId` | - |
| Borrow vaults and user positions | `vaults`, `positions` endpoints | `getAllUserPositions`, `getPositionByVaultId` | - |
| Earn transactions (deposit, withdraw, mint, redeem) | `deposit`, `withdraw`, `mint`, `redeem` or `*-instructions` | - | `getDepositIxs`, `getWithdrawIxs`, `getMintIxs`, `getRedeemIxs` |
| Borrow transactions | `operate`, `operate-instructions` | - | `getInitPositionIx`, `getOperateIx`, etc. |
| Language | Any (HTTP) | TypeScript/JavaScript | TypeScript/JavaScript |

## Data and analytics

### Earn tokens and positions

**REST API:** Fetch available tokens, positions, and earnings via HTTP. See the [Earn API reference](https://developers.jup.ag/docs/api-reference/lend/earn) for endpoints (`tokens`, `positions`, `earnings`), and request formats.

**Read SDK:** Read tokens and positions directly from chain:

```typescript theme={null}
import { Client } from "@jup-ag/lend-read";
import { PublicKey } from "@solana/web3.js";

const client = new Client(connection);

// All token details
const allDetails = await client.lending.getAllJlTokenDetails();

// User positions
const user = new PublicKey("YOUR_WALLET");
const positions = await client.lending.getUserPositions(user);
```

### Vault and Borrow data

**Read SDK:** Vault and position reads:

```typescript theme={null}
// All vaults
const vaults = await client.vault.getAllVaults();

// All positions for a user across vaults
const positions = await client.vault.getAllUserPositions(user);

// Single position by vault and NFT id
const { userPosition, vaultData } = await client.vault.getPositionByVaultId(vaultId, nftId);
```

> [!NOTE]
>
> The Borrow API exposes vault and position reads (`vaults`, `positions`) and operate transactions (`operate`, `operate-instructions`). See the [Borrow API](https://developers.jup.ag/docs/lend/borrow/api.md). The Read SDK remains available for richer on-chain vault and position data.

## On-chain transactions

### Earn deposit and withdraw

**REST API:** Request unsigned transactions or instructions for deposit, withdraw, mint, and redeem. See the [Earn API reference](https://developers.jup.ag/docs/api-reference/lend/earn) for `deposit`, `withdraw`, `mint`, `redeem` and `deposit-instructions`, `withdraw-instructions`, `mint-instructions`, `redeem-instructions` endpoints.

**Lend SDK:** Build instructions directly:

```typescript theme={null}
import { getDepositIxs, getWithdrawIxs } from "@jup-ag/lend/earn";
import BN from "bn.js";

const { ixs: depositIxs } = await getDepositIxs({
  connection,
  signer: userPublicKey,
  asset: usdcMint,
  amount: new BN(1_000_000), // 1 USDC
});

const { ixs: withdrawIxs } = await getWithdrawIxs({
  connection,
  signer: userPublicKey,
  asset: usdcMint,
  amount: new BN(1_000_000),
});
```

### Borrow operations

Borrow API and SDK flows for create-position, deposit, borrow, repay, withdraw, and liquidate are documented in the [Borrow operations](https://developers.jup.ag/docs/lend/borrow.md) pages. For the REST flow, see the [Borrow API](https://developers.jup.ag/docs/lend/borrow/api.md).

## Recommended usage

| Use case | Best option |
| - | - |
| Earn token list and pool details | API or Read SDK |
| Earn user positions | API or Read SDK |
| Earn earnings | API |
| Vault list and config | Read SDK |
| Borrow user positions | Read SDK |
| Earn transactions (deposit, withdraw, mint, redeem) | API or Lend SDK |
| Borrow transactions | Lend SDK |
| Non-JS backend | API |
| On-chain reads and tx building (no API) | Read SDK + Lend SDK |

## Summary

Use the **REST API** for quick integration, earnings data, and unsigned transactions from any backend. Use the **Read SDK** for on-chain Earn and Borrow data (tokens, positions, vaults). Use the **Lend SDK** for transaction instruction building and full control over transaction flow.

## Relevant links

> [card] [API reference (Earn)](https://developers.jup.ag/docs/api-reference/lend/earn)
>
> Deposit, withdraw, mint, redeem, tokens, positions, earnings

> [card] [Read SDK](https://www.npmjs.com/package/@jup-ag/lend-read)
>
> On-chain Earn and Vault data

> [card] [Lend SDK](https://www.npmjs.com/package/@jup-ag/lend)
>
> Instruction builders for Earn and Borrow

> [card] [Jupiter Lend Programs](https://github.com/Instadapp/fluid-solana-programs/)
>
> Jupiter Lend on-chain programs


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.