DEV Community

ambolt
ambolt

Posted on Originally published at ambolt.dev

A free Solana swap API for bots: quote, build, sign, execute

Most swap APIs either hold your keys or ask for a subscription. This one does neither: you ask for a quote, get an unsigned transaction for your own address, sign it in your own code and send it back for execution. Calling the API is free, and Ambolt never holds keys or funds.

The three calls

curl "https://api.ambolt.dev/api/swap/quote?inputMint=So11111111111111111111111111111111111111112&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=10000000"
Enter fullscreen mode Exit fullscreen mode
  1. Quote returns the expected output, the minimum after slippage, price impact, route and the fee, which is already included.
  2. Build (POST /api/swap/build with taker set to your address) returns an unsigned base64 transaction and a requestId.
  3. Execute (POST /api/swap/execute with the signed transaction and the requestId) returns the result and the signature.

Signing with your own key

import { Keypair, VersionedTransaction } from "@solana/web3.js";
import bs58 from "bs58";

const keypair = Keypair.fromSecretKey(bs58.decode(process.env.SOLANA_SECRET_KEY));
const built = await post("build", { inputMint, outputMint, amount: "10000000", slippageBps: 50, taker: keypair.publicKey.toBase58() });
const tx = VersionedTransaction.deserialize(Buffer.from(built.transaction, "base64"));
tx.sign([keypair]);
const result = await post("execute", { signedTransaction: Buffer.from(tx.serialize()).toString("base64"), requestId: built.requestId });
Enter fullscreen mode Exit fullscreen mode

The SDKs wrap the three calls (ambolt.swap.quote, build, execute), and the guide has the same flow in Python and for browser wallets.

Before you sign

  • The build response has checks: takerInTransaction and unsigned must both be true.
  • The fee payer must be your own address. Never sign a transaction whose fee payer is someone else.
  • Quotes are indicative and move with every block.

Limits

The API is rate limited per IP address (a 429 carries Retry-After). It is not investment advice and not a recommendation to trade any token; prices move, tokens can lose value and swaps can fail.

Top comments (0)