endpoints / trade
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
- Price
- $0.005 / call
- Free
- first 100 calls a day
- Freshness
- live, every call
- Auth
- Bearer key
Try it
A real call, charged like any other. Edit anything and run it.
Response
{
"amount": 0.1,
"quote": {
"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,
"route": [
"Pump.fun Amm"
],
"fees": {
"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": "7FVfSdnR9VPGjMtmBP1Hz9C2DFTpoNX8gVVRmnimnGt9",
"signatures_present": 0,
"last_valid_block_height": 453095986,
"priority_fee_lamports": 0,
"compute_unit_limit": 119995,
"simulation": {
"ok": true,
"error": null,
"units_consumed": 96253,
"logs_tail": [
"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 the example answered when this page was built, shortened. Run it for a live answer.
Copy it
Runs as-is with your key in place of c2a_your_key. The snippets follow the inputs above.
curl https://api.crypto2api.com/v1/memecoin/swap \
-H "Authorization: Bearer c2a_your_key" \
-H "Content-Type: application/json" \
-d '{
"mint": "8o9YbJHdhhpJgyPoWDRZBqvJkKCiKZYuVkW6Qpccpump",
"wallet": "7FVfSdnR9VPGjMtmBP1Hz9C2DFTpoNX8gVVRmnimnGt9",
"amount": 0.1,
"side": "buy",
"slippage_bps": 500
}'Parameters
| Name | In | Type | Required | What it is | Example |
|---|---|---|---|---|---|
| mint | body | string | yes | The coin's mint address. | 8o9YbJHdhhpJgyPoWDRZBqvJkKCiKZYuVkW6Qpccpump |
| wallet | body | string | yes | The wallet that will sign and pay. Only its public address. | 7FVfSdnR9VPGjMtmBP1Hz9C2DFTpoNX8gVVRmnimnGt9 |
| amount | body | number | yes | SOL to spend for a buy; tokens to sell for a sell. | 0.1 |
| side | body | string | default buy | "buy" (spend SOL) or "sell" (sell tokens). | buy |
| slippage_bps | body | number | default 500 | Most the price may move before the swap fails, in basis points (100 = 1 %). | 500 |
The answer
Always { data, cost_usd, balance_usd, cached, request_id }. cost_usd is what this call was charged (0 while you are inside the free 100); cached: true means the answer was shared with another caller. A fact the API could not read is left out or named, never estimated.