Lightning Trading API
Buy and sell Pump.fun tokens instantly — one HTTP call = done. No client-side signing, no RPC management — just send the request and get the signature.
API Endpoint: POST https://pumpdev.io/api/trade-lightning?api-key=YOUR_KEY
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
action | string | Yes | "buy" or "sell" |
mint | string | Yes | Token mint address |
amount | number/string | Yes | Amount to trade |
denominatedInSol | string | No | Legacy field name. Set "true" when a buy amount is in the pair's quote asset: SOL for SOL pairs, USDC for USDC pairs. Keep "false" for sell percentages or exact token amounts |
slippage | number | No | Slippage percentage (default: 90) |
priorityFee | number | No | Priority fee in SOL (default: 0.00005) |
jitoTip | number | No | MEV tip in SOL routed to a Jito tip account (default: 0). Add it only when you intentionally want Jito-tip behavior |
computeUnits | number | No | Override compute unit limit. If omitted, PumpDev auto-selects a trade-specific limit |
creator | string | No | Creator public key. Used only as a fallback when the bonding curve is not readable yet (a just-created mint). When PumpDev can read the curve, the on-chain creator wins — a stale value here would make pump.fun reject the transaction with a creator_vault seeds error |
closeTokenAccount | boolean | No | Close the token ATA after selling to reclaim ~0.002 SOL rent. Auto-enabled on "100%" sells. Set false to disable |
Quote mint handling: You do not pass
quoteMinttotrade-lightning. PumpDev resolves the pair quote mint from the token on-chain and uses the correct V2 trade path automatically. Buying a non-SOL pair spends that token (USDC, PUMP, xStocks…) from your wallet, so hold enough of it first — otherwise the request fails withInsufficient quote token balance.
Amount Formats
For buy transactions:
0.1withdenominatedInSol: "true"= Buy with 0.1 SOL25withdenominatedInSol: "true"on a USDC-quoted token = Buy with 25 USDC
For sell transactions:
"100%"= Sell all tokens"50%"= Sell half your tokens1000000withdenominatedInSol: "false"= Sell exact token amount
Response
{
"signature": "5x7...",
"mint": "TokenMintAddress",
"action": "buy",
"publicKey": "YourWalletPublicKey",
}
Buy Example
const response = await fetch(
'https://pumpdev.io/api/trade-lightning?api-key=YOUR_KEY',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'buy',
mint: 'TokenMintAddress',
amount: 0.1,
denominatedInSol: 'true'
})
}
);
const { signature } = await response.json();
console.log('Buy executed:', signature);
Buy a USDC-Quoted Coin
await fetch(
'https://pumpdev.io/api/trade-lightning?api-key=YOUR_KEY',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'buy',
mint: 'UsdcQuotedTokenMint',
amount: 25,
denominatedInSol: 'true'
})
}
);
Sell Examples
Sell 100% of tokens
const response = await fetch(
'https://pumpdev.io/api/trade-lightning?api-key=YOUR_KEY',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'sell',
mint: 'TokenMintAddress',
amount: '100%'
})
}
);
const { signature } = await response.json();
Sell 50% of tokens
body: JSON.stringify({
action: 'sell',
mint: 'TokenMintAddress',
amount: '50%'
})
Sell exact token amount
body: JSON.stringify({
action: 'sell',
mint: 'TokenMintAddress',
amount: 1000000,
denominatedInSol: 'false'
})
Automated Bot Example
Combine WebSocket + Lightning for a fully automated sniper bot:
import WebSocket from 'ws';
const API_URL = 'https://pumpdev.io';
const WS_URL = 'wss://pumpdev.io/ws';
const API_KEY = 'pk_xxxxxxxxxxxxxxxx';
const BUY_AMOUNT_SOL = 0.01;
const MAX_MARKET_CAP_SOL = 50;
let isBuying = false;
const ws = new WebSocket(WS_URL);
ws.on('open', () => {
ws.send(JSON.stringify({ method: 'subscribeNewToken' }));
console.log('Watching for new tokens...');
});
ws.on('message', async (data) => {
const event = JSON.parse(data.toString());
const marketCap = event.marketCapQuote ?? event.marketCapSol ?? 0;
if (
event.txType === 'create' &&
event.quoteMint === 'So11111111111111111111111111111111111111112' &&
marketCap <= MAX_MARKET_CAP_SOL &&
!isBuying
) {
console.log(`New token: ${event.name} (${event.symbol})`);
await buyToken(event.mint);
}
});
async function buyToken(mint) {
isBuying = true;
try {
const response = await fetch(
`${API_URL}/api/trade-lightning?api-key=${API_KEY}`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'buy',
mint: mint,
amount: BUY_AMOUNT_SOL,
denominatedInSol: 'true'
})
}
);
const result = await response.json();
if (result.signature) {
console.log('Buy executed:', result.signature);
} else {
console.log('Error:', result.error);
}
} catch (err) {
console.error('Error:', err.message);
} finally {
isBuying = false;
}
}
With Lightning, your bot never touches private keys. One HTTP call = done — perfect for server-side bots and automated systems.
Error Handling
| Error | Root Cause | Solution |
|---|---|---|
Missing required fields: action, mint, amount | One or more required fields missing | Include all required fields |
action must be 'buy' or 'sell' | Invalid action parameter | Use "buy" or "sell" |
Invalid mint address | Mint address malformed | Verify mint address format |
Token bonding curve not found | Token doesn't exist on Pump.fun | Verify the mint address |
PumpSwap pool not found. Use Jupiter or Raydium for this token. | Graduated token without a PumpSwap pool | Use Jupiter or Raydium instead |
No token balance found | Wallet doesn't hold tokens for sell | Ensure you have tokens for this mint |
Insufficient quote token balance: this coin is priced in <mint>, not SOL… | The coin trades against a token other than SOL and the wallet holds less of it than the buy amount | Get that token into the wallet first, or pick a SOL-paired coin |
Invalid percentage value | Sell percentage is invalid | Use a valid percentage like "50%" or "100%" |
Calculated sell amount is zero | Token balance too small for the percentage | Use "100%" or a larger percentage |
trade-local vs trade-lightning
| Feature | trade-local | trade-lightning |
|---|---|---|
| Signing | You sign locally | Server signs |
| Broadcasting | You send via your RPC | Server sends for you |
| Setup | Need wallet + RPC | Need API key only |
| Control | Full control | Keys on server |
| Speed | Depends on your RPC | Optimized for fastest execution |
| Use case | Client-side, secure keys | Server-side bots, instant trades |
- trade-local: Your keys never leave your machine. Best for client-side apps or when you need maximum security.
- trade-lightning: One HTTP call, server handles everything. Best for server-side bots, snipers, and automated trading where speed matters.
Next Steps
- ⚡ Lightning Setup — Create or import a Lightning wallet
- ⚡ Lightning Create — Create tokens instantly
- ⚡ Lightning Bundle — Trade and create via Jito bundles (MEV protection)
- Trading API — Client-side signing (trade-local)
- Real-Time Data — WebSocket streaming for sniper bots
- Pricing — Commission details