Build Swap API
A buy or sell as an unsigned transaction for your wallet to sign. Simulated first; a failing one is refused.
You send
- mint The coin's mint address
- wallet The wallet that will sign and pay. Only its public address
- amount SOL to spend for a buy; tokens to sell for a sell
+ 3 optional: side, slippage_bps, chain
You get back
JSON with these fields, inside data:
amount, quote, transaction, encoding, fee_payer, signatures_present, …
Example and every field explained ↓It costs
$0.005 / call
The first 100 priced calls a day are free on every key.
- Freshness
- live, every call
- Auth
- Bearer key
- Chains
- 8 chains
curl https://api.crypto2api.com/v1/memecoin/swap \
-H "Authorization: Bearer c2a_your_key" \
-H "Content-Type: application/json" \
-d '{
"mint": "8o9YbJHdhhpJgyPoWDRZBqvJkKCiKZYuVkW6Qpccpump",
"wallet": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"amount": 0.1,
"side": "buy",
"slippage_bps": 500,
"chain": "solana"
}'Swap in your key for c2a_your_key. No key yet? curl -X POST https://api.crypto2api.com/v1/keys makes one, free, no sign-up, or just press Run below.
Used forBuy & sell
Works on 8 chains. Pass chain=; it defaults to solana. Pick one in the playground and the cURL, JavaScript, Python and MCP snippets all follow it.
- solana
- ethereum
- base
- bsc
- arbitrum
- polygon
- avalanche
- optimism
Parameters
Required first. Each example is a value that works.
- mintrequiredbody · string
The coin's mint address.
e.g. 8o9YbJHdhhpJgyPoWDRZBqvJkKCiKZYuVkW6Qpccpump
- walletrequiredbody · string
The wallet that will sign and pay. Only its public address.
e.g. 9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM
- amountrequiredbody · number
SOL to spend for a buy; tokens to sell for a sell.
e.g. 0.1
- sideoptionalbody · string
"buy" (spend SOL) or "sell" (sell tokens).
e.g. buy
default buy
- slippage_bpsoptionalbody · number
Most the price may move before the swap fails, in basis points (100 = 1 %).
e.g. 500
default 500
- chainoptionalbody · string
Which chain: one of the 8 listed above. Default solana.
e.g. solana
default solana
Response
Every answer is { data, cost_usd, balance_usd, cached, request_id }. Below is a real data from this endpoint, read when the page was built.
Example data
Key fields
- amountnumber
- Amount.
- quoteobject
- Quote: amount, mint, side, amount in….
- transactionstring
- The unsigned transaction, base64. Sign it with your wallet and send it.
- encodingstring
- Encoding.
- fee_payerstring
- Fee payer.
- signatures_presentnumber
- Signatures present.
- last_valid_block_heightnumber
- Last valid block height.
- priority_fee_lamportsnumber
- Priority fee lamports.
- compute_unit_limitnumber
- Compute unit limit.
- simulationobject
- What happened when the transaction was simulated before you sign.
2 more fields
- fee_notestring
- Fee note.
- nextstring
- Next.
The wrapper every answer comes in
- data
- The answer itself: the example above.
- cost_usd
- What this one call was charged — 0 while you are inside the free 100 a day.
- balance_usd
- What is left on the key after it.
- cached
- true means the answer was shared with another caller.
- request_id
- Quote this if you report something; it is on your Activity page too.
A fact the API could not read is left out or named, never estimated. When an upstream is down you get a 503 with a stable code you can branch on, not a half-filled answer.
Try it
A real call against the live API. The first 100 priced calls a day are free.
Response
What this example answered when the page was built, shortened. Run it for a live answer.
Copy it
Runs as-is, with your key in place of c2a_your_key. It follows the boxes above, on Solana.
curl https://api.crypto2api.com/v1/memecoin/swap \
-H "Authorization: Bearer c2a_your_key" \
-H "Content-Type: application/json" \
-d '{
"mint": "8o9YbJHdhhpJgyPoWDRZBqvJkKCiKZYuVkW6Qpccpump",
"wallet": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"amount": 0.1,
"side": "buy",
"slippage_bps": 500,
"chain": "solana"
}'Related
Guides that use it
Apps that show this data
Build what these apps show, from code: