📈 Trade Endpoint
Overview
You can trade tokens on PumpFun using the /trade
endpoint. Use any wallet you like by specifying the private key in the request body.
To make trading easy for you, you can specify the SOL amount (e.g., "sols": 0.85
) or the token amount (e.g., "tokens": 1000000
for a million tokens) that you want to buy or sell.
You can also use solsPercentage
(e.g., "solsPercentage": 50
to spend 50% of the sols in your wallet to buy tokens) or tokensPercentage
(e.g., "tokensPercentage": 50
to sell 50% of the tokens in your wallet).
The trade is processed through Jito to ensure quick execution. You can specify the fee
sent to Jito (e.g "fee": 0.003
) and the acceptable slippage
percentage (e.g "slippage": 5
for 5% slippage).
Endpoint
POST https://pumptrader.fun/trade
Request Body
The request body should be a JSON object with the following properties. Additionaly, you'll need to fill in one type of amount property, either sols
, tokens
, solsPercentage
or tokensPercentage
.
Required properties:
Property | Type | Required | Description | Example |
---|---|---|---|---|
tradeType | string | Yes | Type of trade. Possible values are buy or sell . | "buy" |
mint | string | Yes | The token mint public key in base58 format. | "5HueC...eA9" |
slippage | number | Yes | Slippage percentage (1-100) - the max SOLs you accept to spend when buying or the minimum SOLs you accept to receive when selling. | 5 |
fee | number | Yes | The fee for the trade. This is a tip given to jitotip to speed up the transaction. | 0.003 |
privateKey | string | Yes | The private key of the wallet in base58 format. | "5KQwdi...Knk" |
Value property (select one):
Property | Type | Required | Description | Example |
---|---|---|---|---|
sols | number | One of | Amount of SOLs to buy or sell. | 0.85 |
tokens | number | One of | Amount of tokens to buy or sell. | 1000000 |
solsPercentage | number | One of | Percentage of the SOLs in your wallet you want to trade for tokens (buy only). | 50 |
tokensPercentage | number | One of | Percentage of tokens in your wallet you want to sell (sell only). | 75 |
Additional conditions:
tokensPercentage
cannot be used with abuy
trade.solsPercentage
cannot be used with asell
trade.
Response
A successful response will be a JSON object with the following properties:
Property | Type | Description |
---|---|---|
status | number | Status code of the response. |
signature | string | The signature of the trade. |
Examples
- JavaScript
- Python
- Curl
const fetch = require('node-fetch');
const url = "https://pumptrader.fun/trade";
const payload = {
tradeType: "buy",
mint: "5HueCGU8rMjZ3jfj4tX8Cji5m6yXaX1HArhxtk9eA9",
sols: 0.85,
slippage: 5,
fee: 0.003,
privateKey: "5KQwdiF3Z3bE3yKmSPK9FtqWZnyr8L9PU2Dz3M74Knk"
};
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify(payload)
})
const data = await response.json();
import requests
url = "https://pumptrader.fun/trade"
payload = {
"tradeType": "buy",
"mint": "5HueCGU8rMje3jfj4tX8Cji5m6yXaX1HArhxtk9eA9",
"sols": 0.85,
"slippage": 5,
"fee": 0.003,
"privateKey": "5KQwdiF3Z3bE3yKmSPK9FtqWZnyr8L9PU2Dz3M74Knk"
}
response = requests.post(url, json=payload)
data = response.json
curl -X POST https://pumptrader.fun/trade \
-H "Content-Type: application/json" \
-d '{
"tradeType": "buy",
"mint": "5HueCGU8rMjx3jfj4tX8Cji5m6yXaX1HArhxtk9eA9",
"sols": 0.85,
"slippage": 5,
"fee": 0.003,
"privateKey": "5KQwdeF3Z3bE3yKmSPK9FtqWZnyr8L9PU2Dz3M74Knk"
}'