Skip to main content

Local trading

Send a mint and an amount, get back an unsigned transaction, sign it with your own wallet and send it. Your private key never leaves your machine: the API only ever sees your public key.

0.25% per trade, no plan needed

No key and no account needed: anyone can trade. The fee is 0.25% of the SOL side of each trade, taken inside the transaction itself as one transfer. A Koi key works too, at the same fee. Local trading runs in Frankfurt, fra.api.koi.tools, at up to 3 requests a second on each endpoint.

What you needโ€‹

  • A Solana wallet, with its private key in base58, and enough SOL for the trade plus network fees.
  • Node.js or Python, to run the examples as they are.
  • No RPC. Post the signed transaction to /api/send and we broadcast it. Your own RPC works too.

Exampleโ€‹

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

const wallet = Keypair.fromSecretKey(bs58.decode("<your wallet private key, base58>"));

// 1. Build an unsigned transaction.
const res = await fetch("https://fra.api.koi.tools/api/local-trade", {
method: "POST",
headers: { "content-type": "application/json", "accept": "application/json" },
body: JSON.stringify({
action: "buy", // "buy" or "sell"
publicKey: wallet.publicKey.toBase58(),
mint: "<token mint>",
amount: 0.01, // SOL on a buy; tokens or "100%" on a sell
slippage: 10, // percent
priorityFee: 0.0001, // SOL
}),
});
const { tx } = await res.json();

// 2. Sign on your machine: the private key stays in this script.
const signed = VersionedTransaction.deserialize(Buffer.from(tx, "base64"));
signed.sign([wallet]);

// 3. Send it: we broadcast it and wait for confirmation.
const sent = await (await fetch("https://fra.api.koi.tools/api/send", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ signedTx: Buffer.from(signed.serialize()).toString("base64") }),
})).json();
console.log(sent.status, sent.explorer); // "landed" https://solscan.io/tx/โ€ฆ

Request fieldsโ€‹

POST https://fra.api.koi.tools/api/local-trade, a JSON body. With accept: application/json the answer is JSON (below); without it, the raw transaction bytes.

FieldType
action"buy" / "sell"
publicKeystringYour wallet. It signs and pays the network fee.
mintstringThe coin's mint.
amountnumber or stringA buy: how much SOL goes in. A sell: tokens, or a share of what the wallet holds, "100%" for all of it, "50%" for half.
slippagenumberPercent. Default 5.
priorityFeenumberSOL. Default about 0.0002.
poolstringOptional: force a venue (below). Left out, the coin is routed to wherever it trades now, migrations followed.
poolAddressstringFor raydium_cpmm, raydium_amm_v4 and meteora_damm_v2 when we know no pool for the coin yet.
jitoTipnumberSOL. Adds a transfer to a Jito tip account, for sending the signed transaction to a block engine yourself.
settlestringFor a coin priced in something other than SOL (USDC, a stock, another coin): "sol" trades it with SOL in one transaction, left out it is paid in that asset. See Coins not priced in SOL.

The answerโ€‹

{
"tx": "AQAAAAโ€ฆ",
"txVersion": "v0",
"blockhash": "8f3kโ€ฆ",
"feeLamports": 25000,
"feeMint": "SOL",
"quoteMint": "So11111111111111111111111111111111111111112",
"warning": null,
"buildMs": 11.4
}

tx is the unsigned transaction in base64. feeLamports is our 0.25%, in the base units of feeMint. warning says when something about the trade deserves a look before you sign.

Sendingโ€‹

POST https://fra.api.koi.tools/api/send broadcasts one signed transaction, so your bot needs no RPC. It only forwards transactions this API built in the last 15 minutes, unchanged: anything else is refused with not_ours. Using it is optional; a signed transaction can always go through your own RPC.

FieldType
signedTxbase64The signed transaction.
waitbooleanDefault true: wait for confirmation. false answers as soon as the node accepts it.
{ "signature": "5Kdโ€ฆ", "status": "landed", "slot": 372114820, "explorer": "https://solscan.io/tx/5Kdโ€ฆ" }

status is landed (confirmed), failed (it ran and failed on chain; error says why) or pending (not waited for, or not confirmed within 60 seconds). A transaction the node refuses before running it, for too little SOL, slippage or an expired blockhash, comes back as a 400 with the node's reason.

Venuesโ€‹

poolVenue
pumpfunpump.fun bonding curve
pumpswapPumpSwap, where pump.fun coins trade after graduation
bonk, stonkfunRaydium LaunchLab: letsbonk.fun, StonkFun and the other LaunchLab platforms
meteora_dbcMeteora Dynamic Bonding Curve, Bags and Moonshot among them
raydium_cpmmRaydium CPMM, where LaunchLab coins trade after graduation
raydium_amm_v4Raydium AMM v4
meteora_damm_v2Meteora DAMM v2, where DBC coins trade after graduation

Slippage on Meteora DBC is measured against the spot price: leave room on a large buy into a steep curve.

Coins not priced in SOLโ€‹

Some coins are priced in USDC, a tokenised stock or another coin. Such a coin trades in that asset by default: a buy's amount is how much of it to spend, the wallet must hold it, a sell pays out in it, and the fee is taken in it (feeMint says which).

With settle: "sol" it trades with SOL instead: the same transaction swaps the SOL into that asset and back. This transaction is a v1 transaction (txVersion: "v1"), which many libraries cannot read yet: sign the message, every byte but the last 64, with your wallet's key and write the 64-byte signature into those last 64 bytes, then post it to /api/send as usual.

A coin paired with another pump.fun coin needs nothing of this: it is bought and sold with SOL in one multi-hop swap, and the answer carries route and hops.

If something goes wrongโ€‹

The answer is { "error": "โ€ฆ" } with a short message. The usual causes: a wrong wallet address or mint, or not enough SOL. 429 means more than 3 requests a second on that endpoint: wait a second and retry.