HTTP:
https://raptor.solanatracker.io · WebSocket: wss://raptor.solanatracker.io. No API key needed.Swap from a browser wallet
The example uses@solana/web3.js and any wallet that exposes signTransaction (Phantom, Solflare, Wallet Adapter).
Show the price before signing
If the user should confirm the price first, show the quote fields, then build the transaction once they accept. Fetch a new quote if they wait more than a few seconds.Common options
On/quote:
On
/swap:
Raptor creates any token accounts the user is missing and wraps and unwraps SOL inside the transaction. The user pays the rent for new token accounts (about 0.002 SOL each).
Quote and build in one call
When the user doesn’t need to review the price,POST /quote-and-swap takes the quote parameters and the wallet together and returns both:
Build your own transaction
UsePOST /swap-instructions to add your own instructions, such as a memo or a transfer, around the swap. It takes the same body as /swap.
- If the response includes
quoteResponse, the route was rebuilt. Show the user those amounts. /swap-instructionsreturns an ordinary swap that you can also call from your own program through CPI. If you ask forjitRouting: true, the response hastopLevelOnly: true, and the swap must be the last top-level instruction. See JIT routing.
Stream ready-to-sign swaps
/stream/swap sends a new quote and a freshly built transaction whenever the best route changes. When the user clicks Swap, sign the latest transaction and send it. There’s no separate build step.
/stream instead. It takes the same subscribe message without userPublicKey, and its updates have type: "quote" with the quote in data.
Raptor overview
Parameters, JIT routing, errors and supported DEXes.
Transactions
Status values and reading swap results.