Skip to main content

📈 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:

PropertyTypeRequiredDescriptionExample
tradeTypestringYesType of trade. Possible values are buy or sell."buy"
mintstringYesThe token mint public key in base58 format."5HueC...eA9"
slippagenumberYesSlippage percentage (1-100) - the max SOLs you accept to spend when buying or the minimum SOLs you accept to receive when selling.5
feenumberYesThe fee for the trade. This is a tip given to jitotip to speed up the transaction.0.003
privateKeystringYesThe private key of the wallet in base58 format."5KQwdi...Knk"

Value property (select one):

PropertyTypeRequiredDescriptionExample
solsnumberOne ofAmount of SOLs to buy or sell.0.85
tokensnumberOne ofAmount of tokens to buy or sell.1000000
solsPercentagenumberOne ofPercentage of the SOLs in your wallet you want to trade for tokens (buy only).50
tokensPercentagenumberOne ofPercentage of tokens in your wallet you want to sell (sell only).75
Additional conditions:
  • tokensPercentage cannot be used with a buy trade.
  • solsPercentage cannot be used with a sell trade.

Response

A successful response will be a JSON object with the following properties:

PropertyTypeDescription
statusnumberStatus code of the response.
signaturestringThe signature of the trade.

Examples

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();