Skip to content

Build Swap API

A buy or sell as an unsigned transaction for your wallet to sign. Simulated first; a failing one is refused.

POST/v1/memecoin/swap

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.

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

"amount": 0.1,
"amount": 0.1,
"mint": "8o9YbJHdhhpJgyPoWDRZBqvJkKCiKZYuVkW6Qpccpump",
"side": "buy",
"amount_in": 0.1,
"in_unit": "SOL",
"expected_out": 506340.116307,
"out_unit": "tokens",
"min_out": 481023.110492,
"price_impact_pct": 0.0178,
"slippage_bps": 500,
"Pump.fun Amm"
],
"route_fee_sol": 0,
"network_fee_sol": 0.000005,
"crypto2api_fee_usd": 0
},
"value_usd": 7.0431073770534,
"price_usd": 0.000013909834813054949
},
"transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA… (base64, 792 chars)",
"encoding": "base64",
"fee_payer": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"signatures_present": 0,
"last_valid_block_height": 453095986,
"priority_fee_lamports": 0,
"compute_unit_limit": 119995,
"ok": true,
"error": null,
"units_consumed": 96253,
"Program JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 consumed 64181 of 88041 compute units",
"Program return: JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 Uwc55HUAAAA=",
"Program JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 success"
]
},
"fee_note": "crypto2api adds no fee instruction to this transaction (quote.fees.crypto2api_fee_usd is 0).",
"next": "The simulation passed. Have the wallet sign this transaction and send it. It is unsigned; nothing here has or wants a private key."
}

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

"amount": 0.1,
"amount": 0.1,
"mint": "8o9YbJHdhhpJgyPoWDRZBqvJkKCiKZYuVkW6Qpccpump",
"side": "buy",
"amount_in": 0.1,
"in_unit": "SOL",
"expected_out": 506340.116307,
"out_unit": "tokens",
"min_out": 481023.110492,
"price_impact_pct": 0.0178,
"slippage_bps": 500,
"Pump.fun Amm"
],
"route_fee_sol": 0,
"network_fee_sol": 0.000005,
"crypto2api_fee_usd": 0
},
"value_usd": 7.0431073770534,
"price_usd": 0.000013909834813054949
},
"transaction": "AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA… (base64, 792 chars)",
"encoding": "base64",
"fee_payer": "9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM",
"signatures_present": 0,
"last_valid_block_height": 453095986,
"priority_fee_lamports": 0,
"compute_unit_limit": 119995,
"ok": true,
"error": null,
"units_consumed": 96253,
"Program JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 consumed 64181 of 88041 compute units",
"Program return: JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 Uwc55HUAAAA=",
"Program JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4 success"
]
},
"fee_note": "crypto2api adds no fee instruction to this transaction (quote.fees.crypto2api_fee_usd is 0).",
"next": "The simulation passed. Have the wallet sign this transaction and send it. It is unsigned; nothing here has or wants a private key."
}

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

More in Trade

All endpoints →