Skip to main content
During development, you can use the developer endpoints without an API key. For production use, you’ll need an API key to avoid rate limits.
With imperative trades, builders define the exact execution path for a trade, including which venues are used and how the transaction is constructed. Use imperative trades when you need deterministic routing, venue control, or strategy-driven execution. The API aggregates liquidity across major Solana DEXs, so builders can execute trades on any SPL token while retaining full control over how execution happens. To execute an imperative trade, request an order from /order (with userPublicKey), sign it, and submit it to your RPC.
1

Request an Order

Request an order from /order using userPublicKey, input/output mints, amount, slippage, and your execution path. The response returns a base64-encoded transaction. Use dexes to enforce a deterministic path (for example, a single venue).
const connection = new Connection(SOLANA_RPC_URL, "confirmed");
const keypair = getKeypair();

const inputMint = "So11111111111111111111111111111111111111112"; // SOL
const outputMint = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"; // USDC
const inputAmount = 100000; // 0.0001 SOL (9 decimals)
const slippageBps = 50; // 0.5%
const dexes = ["Raydium AMM"]; // single venue for deterministic path

const order = await fetchOrder({
  userPublicKey: keypair.publicKey.toBase58(),
  inputMint,
  outputMint,
  amount: inputAmount,
  slippageBps,
  dexes,
});
2

Sign the Transaction

Deserialize the base64 transaction and sign it with the user’s keypair.
const transactionBuffer = Buffer.from(order.transaction, "base64");
const tx = VersionedTransaction.deserialize(transactionBuffer);
tx.sign([keypair]);
3

Submit the Transaction

Submit the signed transaction to a Solana RPC and wait for confirmation.
const signature = await connection.sendRawTransaction(tx.serialize(), {
  skipPreflight: false,
});

console.log(`Transaction sent: ${signature}`);

await connection.confirmTransaction(signature, "confirmed");
console.log("Transaction confirmed");

await sendTransaction(connection, tx);

API Routes

Cookbook Repository

This recipe, along with many more, is available in the DFlow Cookbook Repo. You can clone it and start coding immediately.