> For the complete documentation index, see [llms.txt](https://docs.triton.one/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.triton.one/solana/sending-transactions/3rd-party-apis/titan-swap-api.md).

# Titan Swap API

Stream or poll Titan swap quotes over WebSocket or HTTPS on the /titan path of your Triton Solana mainnet endpoint.

Titan is Titan Exchange's swap-routing service, available through your Triton Solana mainnet endpoint.

## Use cases

* Trading interfaces that need live price updates
* Price-monitoring dashboards
* Trading bots that need low-latency price feeds
* Wallets with live swap pricing

## Features and benefits

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><i class="fa-layer-group">:layer-group:</i> <strong>Meta-aggregation</strong></td><td>Titan sources routes from Argos, external aggregators and RFQ sources, simulates each route, and returns executable routes.</td><td></td></tr><tr><td><i class="fa-route">:route:</i> <strong>DART on-chain routing</strong></td><td>Dynamically Allocated Real-Time routing re-optimizes how your volume splits across pools on-chain at execution, on selected pairs.</td><td></td></tr><tr><td><i class="fa-tower-broadcast">:tower-broadcast:</i> <strong>Live quote streaming</strong></td><td>A single WebSocket channel pushes continuous quotes, each with route data and swap instructions. Quotes can also include a ready-to-sign transaction for your wallet.</td><td></td></tr><tr><td><i class="fa-coins">:coins:</i> <strong>Bandwidth billing</strong></td><td>Billed on bandwidth, with no per-request charge.</td><td></td></tr></tbody></table>

## Getting started

Titan is enabled by default on Triton's Solana mainnet endpoints for every active Solana subscription, on both shared RPC pools and dedicated nodes. Add the `/titan` path to your endpoint URL (find it in your [customer dashboard](https://customers.triton.one)), followed by Titan's API path:

* **Stream** (recommended): connect over `wss://` to `/titan/api/v1/ws` and receive continuous quote updates, faster than polling and without repeated HTTP requests.
* **Poll**: request quotes over `https://` with `GET /titan/api/v1/quote/swap`.

Stream messages are MessagePack, not JSON. The TypeScript SDK below handles the stream encoding for you; it doesn't make REST calls. Poll responses also default to MessagePack, so decode them with a MessagePack library such as `@msgpack/msgpack`, or send `Accept: application/json` with `GET /titan/api/v1/quote/swap` to get JSON instead.

```url
wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>/titan/api/v1/ws
```

### Example connection

```typescript
import { V1Client } from "@titanexchange/sdk-ts";
import bs58 from "bs58";

const client = await V1Client.connect(
  "wss://<your-endpoint>.mainnet.rpcpool.com/<your-token>/titan/api/v1/ws",
);

const { stream } = await client.newSwapQuoteStream({
  swap: {
    inputMint: bs58.decode("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"), // USDC
    outputMint: bs58.decode("So11111111111111111111111111111111111111112"), // wrapped SOL
    amount: 1_000_000, // raw amount: 1 USDC
  },
  transaction: {
    userPublicKey: bs58.decode("<your-wallet-public-key>"),
  },
});

for await (const update of stream) {
  for (const [provider, route] of Object.entries(update.quotes)) {
    console.log(provider, route.outAmount, route.instructions.length);
  }
}
```

### Executing a swap

{% stepper %}
{% step %}

#### Connect

Open the WebSocket as shown above.
{% endstep %}

{% step %}

#### Request quotes

Send a `NewSwapQuoteStream` request with your swap parameters (the SDK's `newSwapQuoteStream()`).
{% endstep %}

{% step %}

#### Receive the stream

Get continuous updates, each a map of provider ID to route. Not every provider appears in every update.
{% endstep %}

{% step %}

#### Select a quote

Choose by your criteria, such as price or provider.
{% endstep %}

{% step %}

#### Execute

Quotes are built for the `userPublicKey` you send. Each `SwapRoute` carries the instructions and address lookup tables to build your own transaction, and can also carry a ready-to-sign `transaction`. Sign and submit whichever you use.
{% endstep %}
{% endstepper %}

For the request and response format and the full execution flow, see the [Titan Swap API reference](https://titan-exchange.gitbook.io/titan/developer-doc/swap-api/reference). Titan's [DART overview](https://titan-exchange.gitbook.io/titan/developer-doc/dart-swap-api/overview) documents a standalone DART API with its own endpoint, separate from `/titan`. The example uses the TypeScript SDK, [@titanexchange/sdk-ts](https://www.npmjs.com/package/@titanexchange/sdk-ts).

Triton's launch post, [Titan Prime API for Solana Swaps on Triton](https://blog.triton.one/titan-prime-api-for-solana-swaps-is-live-on-triton/), covers the service under the name Titan Prime and its WebSocket quote streaming. The post's launch pricing no longer applies; see [pricing](https://triton.one/pricing).

## Pricing

Titan is billed on bandwidth, including polls. See [pricing](https://triton.one/pricing).

***

<i class="fa-life-ring">:life-ring:</i> Contact support by clicking the chat icon in your [customer dashboard](https://customers.triton.one)\ <i class="fa-briefcase">:briefcase:</i> Sales questions? [Contact us](https://triton.one/contact)\ <i class="fa-sparkles">:sparkles:</i> AI agent? Read [llms.txt](https://docs.triton.one/llms.txt)\ <i class="fa-rss">:rss:</i> Follow updates: [Blog](https://blog.triton.one) · [X](https://x.com/triton_one) · [YouTube](https://www.youtube.com/@triton_one_ltd) · [Telegram](https://t.me/tritonone) · [GitHub](https://github.com/rpcpool)
