> For the complete documentation index, see [llms.txt](https://titan-exchange.gitbook.io/titan/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://titan-exchange.gitbook.io/titan/developer-doc/dart-swap-api/how-to-use.md).

# How to Use

The DART API is a standard **JSON REST API** — no MessagePack, no WebSocket. Just HTTP requests. Free to use without an API key, or pass a key for higher rate limits (see [Get API Access](/titan/developer-doc/dart-swap-api/get-api-access.md)).

**Base URL:** `https://api.titan.exchange/dart`

***

## `GET /health`

Health check.

```bash
curl https://api.titan.exchange/dart/health
```

```json
{ "status": "ok" }
```

***

## `GET /markets`

Returns the list of supported trading pairs.

```bash
curl https://api.titan.exchange/dart/markets
```

```json
{
  "markets": [
    {
      "name": "SOL/USDC",
      "tokenA": "So11111111111111111111111111111111111111112",
      "tokenB": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    }
  ]
}
```

***

## `POST /swap`

Get a swap quote with transaction-ready instructions. Compute budget instructions are pre-configured for optimal execution.

**Request body (JSON):**

* **`inputMint`** (string, required) — Input token mint address (base58).
* **`outputMint`** (string, required) — Output token mint address (base58).
* **`amount`** (string, required) — Raw amount in smallest unit (e.g. lamports).
* **`userPublicKey`** (string, required) — Wallet public key (base58). Must be on-curve.
* **`slippageBps`** (number, optional) — Slippage tolerance in basis points. Default: `50`.
* **`computeUnitPrice`** (number, optional) — Compute unit price in microLamports. Default: `10000`.
* **`includeDexes`** (string\[], optional) — Only use these DEX venues.
* **`excludeDexes`** (string\[], optional) — Exclude these DEX venues.

**Example:**

```bash
curl -X POST https://api.titan.exchange/dart/swap \
  -H "Content-Type: application/json" \
  -d '{
    "inputMint": "So11111111111111111111111111111111111111112",
    "outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
    "amount": "1000000000",
    "userPublicKey": "YourWalletPublicKeyHere"
  }'
```

**Response:**

```json
{
  "outputAmount": "84550000",
  "inputAmount": "1000000000",
  "provider": "Titan-DART",
  "slippageBps": 50,
  "instructions": [
    {
      "programId": "ComputeBudget111111111111111111111111111111",
      "accounts": [],
      "data": "AQAABAA="
    },
    {
      "programId": "ComputeBudget111111111111111111111111111111",
      "accounts": [
        {
          "pubkey": "jitodontfronttitandart111111111111111111111",
          "isSigner": false,
          "isWritable": false
        }
      ],
      "data": "AsBcFQA="
    },
    {
      "programId": "ComputeBudget111111111111111111111111111111",
      "accounts": [],
      "data": "AxAnAAAAAAAA"
    },
    {
      "programId": "T1TANpTeScyeqVzzgNViGDNrkQ6qHz9KrSBS4aNXvGT",
      "accounts": [
        {
          "pubkey": "YourWalletPublicKeyHere",
          "isSigner": true,
          "isWritable": true
        }
      ],
      "data": "..."
    }
  ],
  "addressLookupTables": [
    "RyXhBMnPkYJyWEkBmYAnW7A8LCKfrEgAABB2xVZrwy3"
  ]
}
```

**Response fields:**

* **`outputAmount`** — Expected output in smallest unit.
* **`inputAmount`** — Input amount in smallest unit.
* **`provider`** — Always `Titan-DART`.
* **`slippageBps`** — Slippage tolerance applied.
* **`instructions`** — Swap instructions with compute budget pre-configured. `programId` and `pubkey` are base58, `data` is base64.
* **`addressLookupTables`** — Base58 address lookup table keys for V0 transaction compilation.

**Compute budget (prepended automatically):**

* **`requestHeapFrame`** — 256 KB
* **`setComputeUnitLimit`** — 1,400,000 CUs
* **`setComputeUnitPrice`** — configurable (default 10,000 microLamports)

**Errors:**

* **`400`** — Missing required fields or invalid JSON.
* **`404`** — No routes found for the given pair.
* **`429`** — Rate limit exceeded.

***

## Building a transaction

The response includes all instructions ready to go — deserialize, build a V0 transaction, sign, and send:

```typescript
import {
  Connection,
  PublicKey,
  TransactionInstruction,
  TransactionMessage,
  VersionedTransaction,
} from "@solana/web3.js";

// 1. Deserialize instructions from the response
const instructions = response.instructions.map(
  (ix) =>
    new TransactionInstruction({
      programId: new PublicKey(ix.programId),
      keys: ix.accounts.map((acc) => ({
        pubkey: new PublicKey(acc.pubkey),
        isSigner: acc.isSigner,
        isWritable: acc.isWritable,
      })),
      data: Buffer.from(ix.data, "base64"),
    })
);

// 2. Fetch address lookup tables
const connection = new Connection("https://api.mainnet-beta.solana.com");
const altAccounts = await Promise.all(
  response.addressLookupTables.map(async (key) => {
    const alt = await connection.getAddressLookupTable(new PublicKey(key));
    return alt.value;
  })
);

// 3. Build V0 transaction
const { blockhash } = await connection.getLatestBlockhash();
const message = new TransactionMessage({
  payerKey: walletPublicKey,
  recentBlockhash: blockhash,
  instructions,
}).compileToV0Message(altAccounts.filter(Boolean));

const transaction = new VersionedTransaction(message);

// 4. Sign and send
transaction.sign([wallet]);
const signature = await connection.sendTransaction(transaction);
```

***

## Related pages

* [Overview](/titan/developer-doc/dart-swap-api/overview.md) — What DART is, supported pairs, and fees
* [Get API Access](/titan/developer-doc/dart-swap-api/get-api-access.md) — Rate limits and higher-rate access
