Skip to main content

Buy and Sell – API

Use this to buy and sell tokens.
Supported pools

  • Pump.fun
  • Raydium LaunchPad (including bonk)
  • Meteora LaunchPad (including Bags.fm, moonshot)
  • PumpSwap
  • Raydium CPMM

Endpoint

POST https://api.pumpapi.io

Request Body

FieldDescription
publicKeyYour public key (the wallet address)
action"buy" or "sell"
mintMint address of the token
quoteMintOptional. Not required. It works only if such pools exist. By default, the quote mint is So11111111111111111111111111111111111111112, so you don’t need to set it — we handle it automatically. But if you trade in pools where Solana is not the second token (for example, a Memecoin–USDC pair), then quoteMint should be the USDC address (or the address of any other quote token).
poolIdOptional. Not required. provide this if you need to trade token from the specific pool.
amountAmount to trade. Use '100%' to sell all and get a 0.002 sol refund from the network
denominatedInQuote"true" if amount is in SOL (or any other quote token), "false" for token amount
slippageSlippage in percent (recommended: 20)
priorityFeeOptional priority fee in SOL

import requests
from solders.transaction import VersionedTransaction
from solders.keypair import Keypair
from solders.commitment_config import CommitmentLevel
from solders.rpc.requests import SendVersionedTransaction
from solders.rpc.config import RpcSendTransactionConfig

response = requests.post(url="https://api.pumpapi.io", data={
"publicKey": "your_public_key",
"action": "buy", # or sell
"mint": "token_address",
"amount": 0.01,
"denominatedInQuote": "true",
"slippage": 20,
"priorityFee": 0.0001,
})

keypair = Keypair.from_base58_string("your_private_key")
tx = VersionedTransaction(VersionedTransaction.from_bytes(response.content).message, [keypair])

commitment = CommitmentLevel.Confirmed
config = RpcSendTransactionConfig(preflight_commitment=commitment)
txPayload = SendVersionedTransaction(tx, config)

response = requests.post(
url="https://api.mainnet-beta.solana.com/", # it's better to use Helius RPC endpoint
headers={"Content-Type": "application/json"},
data=SendVersionedTransaction(tx, config).to_json()
)
txSignature = response.json()['result']
print(f'Transaction: https://solscan.io/tx/{txSignature}')
tip

Want cleaner code and faster execution? Use our ⚡ Lightning transactions


Need help? Join our Telegram group.