POST /v1/tx/swap
Builds an unsigned transaction to trade a token against a supported quote asset. This is the single endpoint for buys and sells.
- Auth: required (see API Authentication)
- Errors: see Errors
- Method:
POST - Path:
/v1/tx/swap
Headers
Section titled “Headers”Authorization: Bearer api_your_key_hereContent-Type: application/jsonHow to Think About a Swap
Section titled “How to Think About a Swap”Every swap has two sides:
inputMint: the mint that goes into the DEXoutputMint: the mint that comes out of the DEX
For most trades, one side is your token and the other side is one of the supported assets:
| Asset | Mint |
|---|---|
| SOL | So11111111111111111111111111111111111111111 |
| WSOL | So11111111111111111111111111111111111111112 |
| USDC | EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v |
{ "inputMint": "<mint going into the DEX>", "outputMint": "<mint coming out of the DEX>", "amount": 0.1, "swapMode": "exactIn", "slippage": 0.05, "priority": "fast"}Fields
Section titled “Fields”inputMint(string, required): mint that goes into the DEX.outputMint(string, required): mint that comes out of the DEX.amount(number, required): Human unit amount for the side selected byswapMode.swapMode(string, required):exactIn:amountis the exact input amount. Use this for most buys and sells.exactOut:amountis the exact output amount. Use this when you need to receive exactly a specific amount.
slippage(number, required): max allowed slippage as a decimal (0 ≤ slippage < 1). Example:0.05= 5%priority(string, required): see Priority (economy|fast|faster|fastest)
Response
Section titled “Response”{ "success": true, "data": { "submissionToken": "txn_…", "unsignedTransaction": "BASE64_WIRE_TRANSACTION", "expiresAt": "2025-01-01T00:00:00.000Z", "platform": "pump_fun", "inputMint": "So11111111111111111111111111111111111111112", "outputMint": "TOKEN_MINT", "estimates": { "inputAmount": 0.1, "outputAmount": 3529922.965, "priceImpact": 0.00346 }, "priorityCost": 0.000005125 }}submissionTokenlinks this built transaction for submission viaPOST /v1/tx/submit.inputMint/outputMintin the response match what you sent in the request.estimatesare best-effort outputs assuming the market doesn’t move between build and execution.priceImpactshows how much your trade will move the price;0.1means ~10% price impact.priorityCostis the actual priority fee for this transaction. Check this before signing if you have cost limits.
Supported quote assets are SOL, WSOL and USDC.
Examples
Section titled “Examples”Buy a token with SOL
Section titled “Buy a token with SOL”Spend exactly 0.1 SOL to receive as many tokens as possible. The quote asset goes in, your token comes out.
{ "inputMint": "So11111111111111111111111111111111111111112", "outputMint": "TOKEN_MINT", "amount": 0.1, "swapMode": "exactIn", "slippage": 0.05, "priority": "fast"}Sell a token for SOL
Section titled “Sell a token for SOL”Sell exactly 1 000 000 tokens and receive as much SOL as possible. Your token goes in, the quote asset comes out.
{ "inputMint": "TOKEN_MINT", "outputMint": "So11111111111111111111111111111111111111112", "amount": 1000000, "swapMode": "exactIn", "slippage": 0.05, "priority": "fast"}Buy a token with USDC
Section titled “Buy a token with USDC”Spend exactly 10 USDC to buy a token on a USDC pair.
{ "inputMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", "outputMint": "TOKEN_MINT", "amount": 10, "swapMode": "exactIn", "slippage": 0.05, "priority": "fast"}