Solana swap API
Free to call. Quote a swap, get an unsigned transaction for your address, sign it yourself and send it for execution. Ambolt never holds keys or funds, and the fee is shown in every quote.
| Step | Request | Returns |
|---|---|---|
| Quote | GET https://api.ambolt.dev/api/swap/quote | Expected output, minimum after slippage, price impact, route and fee |
| Build | POST https://api.ambolt.dev/api/swap/build | An unsigned base64 transaction and a requestId |
| Execute | POST https://api.ambolt.dev/api/swap/execute | The result and, on success, the transaction signature |
Parameters
inputMint,outputMint: token mint addresses (SOL isSo11111111111111111111111111111111111111112, USDC isEPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v). Use mint addresses, not symbols.amount: the input amount in its smallest unit, as a string (lamports for SOL).slippageBps: optional, 1 to 500.taker: your wallet address, required for build.
1. Quote
curl "https://api.ambolt.dev/api/swap/quote?inputMint=So11111111111111111111111111111111111111112&outputMint=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v&amount=10000000"
2. Build, sign and execute: JavaScript
Works with any key you can load in Node: a keypair file, an environment variable or your own signer. Keep the key out of the code and use a wallet with a small balance.
import { Keypair, VersionedTransaction } from "@solana/web3.js";
import bs58 from "bs58";
const API = "https://api.ambolt.dev/api/swap";
const keypair = Keypair.fromSecretKey(bs58.decode(process.env.SOLANA_SECRET_KEY));
const post = (path, body) => fetch(`${API}/${path}`, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) }).then(r => r.json());
const built = await post("build", {
inputMint: "So11111111111111111111111111111111111111112",
outputMint: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
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,
});
console.log(result.status, result.signature);
2. Build, sign and execute: Python
import base64, os, requests
from solders.keypair import Keypair
from solders.transaction import VersionedTransaction
API = "https://api.ambolt.dev/api/swap"
kp = Keypair.from_base58_string(os.environ["SOLANA_SECRET_KEY"])
built = requests.post(f"{API}/build", json={
"inputMint": "So11111111111111111111111111111111111111112",
"outputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
"amount": "10000000", "slippageBps": 50, "taker": str(kp.pubkey()),
}).json()
tx = VersionedTransaction.from_bytes(base64.b64decode(built["transaction"]))
signed = VersionedTransaction(tx.message, [kp])
result = requests.post(f"{API}/execute", json={
"signedTransaction": base64.b64encode(bytes(signed)).decode(),
"requestId": built["requestId"],
}).json()
print(result.get("status"), result.get("signature"))
Browser wallets and other signers
The transaction is a standard versioned Solana transaction, so any signer that can sign one will do. In a web app, deserialize it, ask the connected wallet to sign it (wallet adapter signTransaction, or the Wallet Standard solana:signTransaction feature), then post the signed bytes as base64 to /execute with the same requestId. Hardware wallets and multisig tools work the same way: build with taker set to their address and sign through their own flow. The swap page is a working example of the browser flow.
Checks before you sign
- The build response includes
checks:takerInTransactionandunsignedmust both be true. - The fee payer must be your own address. Do not sign a transaction whose fee payer is someone else.
- Quotes are indicative and change with every block; execution uses the build you signed.
Limits and errors
Free to call, with a rate limit per IP address (429 with Retry-After). 400 means invalid input and the message names the problem; 422 means no route or not enough balance for this swap; failed swaps are never charged by Ambolt, and network fees apply only to executed transactions.
Not investment advice and not a recommendation to trade any token. Prices move, tokens can lose value and swaps can fail. Guide for trading bots and agents covers token search, facts and prices.