Skip to main content
Four calls, always in the same order: quote, execute, complete, then status. Every call below works as-is with no API key. But get a free key first if you can, it takes 30 seconds, quadruples your rate limit, and gets your project on RAVN’s radar.
Charging a fee? A fee only applies to calls that send your key as x-api-key. A swap then only pays you when your code pays the fee an execution asks for and reports the swap to /status, with that payment’s hash, until it is final. The script in steps 3 and 4 does all of that. Collecting your fee is the checklist.
Want to run the whole flow without moving real funds? Add sandbox: true to the quote in step 1 and every later call sees it automatically (the script in step 3 does this with SANDBOX=1). Every sandbox execution carries "sandbox": true, and nothing is opened at any venue: this pair’s usual winner, Chainflip, comes back as a stand-in deposit to your user’s own wallet. Other venues return their real, signable transaction, which swaps for real if you broadcast it, so never send an execution marked sandbox. See Sandbox Mode.
1

Get a quote

Price the swap. You get back the best route across every venue plus an opaque quoteToken. The two addresses are well-formed placeholders, so the call runs as-is: nobody holds their keys, so funds sent to them are lost. Add -H 'x-api-key: rvn_live_…' to quote with your fee.
2

Execute

Hand the quoteToken back. RAVN returns how to complete the swap, tagged by executionType.
3

Complete it

Branch on executionType. This is the entire client-side contract, unless you quote with broadcastViaRavn: then a TRANSACTION carrying submit is signed and posted to /submit-transaction, never broadcast.The code from here to the end of step 4 is one Node script for an EVM wallet. It quotes the same swap from that wallet, then sends exactly what RAVN returns, for real. Save it as quickstart.mjs, npm install viem, and run it with Node 20+: PRIVATE_KEY=0x… SOL_DESTINATION=<your Solana wallet> RAVN_API_KEY=rvn_live_… node quickstart.mjs (the key is optional, and needed only for your fee). Add SANDBOX=1 for a test run that sends and signs nothing, with any throwaway PRIVATE_KEY.
Skipping the approval wait is the most common integration failure. The swap spends your tokens via transferFrom, so if the allowance is not yet mined it reverts and the user loses the gas. Wait for the receipt, not just the broadcast. Native-coin sells never carry approval, and RAVN leaves it out when it reads, at /execute, that your user’s allowance already covers approval.amount. When that read fails it is included anyway, so read allowance(user, approval.spender) yourself and skip it when it covers the amount, as approve() above does. The read sees the latest block only: run one swap per token and spender at a time. An approval.reset (Ethereum USDT holding a partial allowance), an approve(spender, 0), goes first, mined.It appears on SIGNATURE too: gasless venues still pull tokens via transferFrom, and skipping it there is quieter and worse: the order is accepted and never fills, with no error. See Execution types.
On JS/TS, @ravnexchange/sdk’s executeAndTrack does this switch for TRANSACTION and SIGNATURE, given your own sign/send functions: approval.reset, the approval wait, approvalData, the fee payment (give it a waitForReceipt that returns the receipt), sandbox executions (it sends nothing) and status polling with retries (SDK 0.2.0). For a DEPOSIT it returns feePayment and statusRef; you send the deposit and fee and poll yourself, unless you pass sendDeposit: true (SDK 0.2.4), which sends the deposit and RAVN’s fee from the ready-made payload and tracks it. With it on, send a deposit yourself only when the result has depositNotSent, or your user pays twice.
4

Track it

Poll status with the quoteToken that execute returned (not the one from step 1), and as ref: the statusRef from execute (DEPOSIT, and TRANSACTION when present), the statusRef from submit-signature (SIGNATURE), or otherwise the transaction hash you broadcast (TRANSACTION). When you sent a fee payment, pass its hash as txHash on every poll.
Poll every swap to a final status. That poll is what marks the swap settled in RAVN’s ledger, and only settled swaps count toward a fee payout. See Settlement.
Amounts are strings in the token’s smallest unit. Native coin uses the sentinel 0xEeee...EEeE. The quoteToken is opaque, so never parse it. It expires, so re-quote if it goes stale.