Are you a developer looking to automate token creation on pump.fun? Want to build a trading bot that can buy and sell memecoins programmatically? Or maybe you need to launch tokens with atomic multi-wallet purchases using Jito bundles?
This comprehensive guide covers everything you need to know about integrating with pump.fun API using JavaScript/TypeScript. By the end, you'll understand how to create tokens, execute trades, stream real-time market data, and build sophisticated trading systems on Solana #1 memecoin launchpad.
π― What is Pump.fun and Why Do Developers Need an API?
Pump.fun has become the dominant platform for launching memecoins on Solana. With thousands of tokens created daily and millions in trading volume, it's a goldmine for developers building automated trading systems.
Challenges of Manual Interaction
However, manually interacting with pump.fun presents several challenges:
- Speed matters: In memecoin trading, milliseconds can mean the difference between profit and loss
- Multi-wallet operations: Launching tokens with multiple buyers requires coordination
- Front-running risk: Without atomic execution, your dev buys can be front-run
- Monitoring at scale: Tracking new launches and trades manually is impossible
π‘ Solution: A pump.fun API solves these problems by providing programmatic access to all platform operations with client-side signing (your private keys never leave your machine).
π§ PumpDev API Overview
PumpDev.io provides the most comprehensive pump.fun API available:
| Feature | Endpoint | Description |
|---|---|---|
| Token Creation | /api/create |
Create tokens with optional dev buy |
| Jito Bundle Launch | /api/create-bundle |
Atomic create + multiple buyers |
| Buy/Sell Trading | /api/trade-local |
Generate buy/sell transactions |
| Bundle Sell | /api/trade-bundle |
Multi-wallet sells in one request |
| Creator Fees | /api/claim-account |
Claim your 1% creator royalties |
| SOL Transfers | /api/transfer |
Wallet management operations |
| Real-Time Data | WebSocket | Stream trades and new launches |
β¨ Key Benefits
- β Client-side signing β Private keys never leave your machine
- β Jito bundle support β Atomic execution, no front-running
- β 0.25% commission β Lowest fees (competitors charge 1%)
- β Free WebSocket β Unlimited real-time data streaming
- β PumpSwap routing β Automatic support for graduated tokens
π Getting Started: Your First Token Purchase
Let's start with a simple example β buying tokens on pump.fun using the API.
Buy Tokens with JavaScript
import { VersionedTransaction, Connection, Keypair } from '@solana/web3.js';
import bs58 from 'bs58';
async function buyToken(privateKey, mint, amountSol) {
const keypair = Keypair.fromSecretKey(bs58.decode(privateKey));
const publicKey = keypair.publicKey.toBase58();
console.log('Wallet:', publicKey);
console.log('Token:', mint);
console.log('Amount:', amountSol, 'SOL');
// 1. Request buy transaction from PumpDev API
const response = await fetch('https://pumpdev.io/api/trade-local', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
publicKey: publicKey,
action: 'buy',
mint: mint,
amount: amountSol,
denominatedInSol: 'true',
slippage: 15,
priorityFee: 0.0005
})
});
if (response.status !== 200) {
const error = await response.json();
throw new Error(error.error);
}
// 2. Deserialize the unsigned transaction
const data = await response.arrayBuffer();
const tx = VersionedTransaction.deserialize(new Uint8Array(data));
// 3. Sign with your wallet (keys never leave your machine!)
tx.sign([keypair]);
// 4. Send to Solana network
const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
const signature = await connection.sendTransaction(tx, {
skipPreflight: false,
maxRetries: 3
});
console.log('β
Transaction sent!');
console.log('Signature:', signature);
// 5. Wait for confirmation
await connection.confirmTransaction(signature, 'confirmed');
console.log('Transaction confirmed!');
return signature;
}
Selling Tokens
Selling is just as simple. The API supports percentage-based sells:
async function sellToken(privateKey, mint, percentage = '100%') {
const keypair = Keypair.fromSecretKey(bs58.decode(privateKey));
const response = await fetch('https://pumpdev.io/api/trade-local', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
publicKey: keypair.publicKey.toBase58(),
action: 'sell',
mint: mint,
amount: percentage, // '100%', '50%', '25%', or exact amount
denominatedInSol: 'false',
slippage: 15,
priorityFee: 0.0005
})
});
const data = await response.arrayBuffer();
const tx = VersionedTransaction.deserialize(new Uint8Array(data));
tx.sign([keypair]);
const connection = new Connection('https://api.mainnet-beta.solana.com', 'confirmed');
const signature = await connection.sendTransaction(tx);
console.log('β
Sell transaction sent:', signature);
return signature;
}
π¨ Creating Tokens on Pump.fun
Now let's look at the real power of the pump.fun API β programmatic token creation.
Step 1: Upload Metadata to IPFS
async function uploadMetadata(imageUrl, name, symbol, description) {
const formData = new FormData();
const imageResponse = await fetch(imageUrl);
const imageBuffer = await imageResponse.arrayBuffer();
formData.append('file', new Blob([imageBuffer], { type: 'image/jpeg' }), 'token.jpg');
formData.append('name', name);
formData.append('symbol', symbol);
formData.append('description', description);
formData.append('twitter', 'https://twitter.com/mytoken');
formData.append('telegram', 'https://t.me/mytoken');
formData.append('website', 'https://mytoken.com');
formData.append('showName', 'true');
const res = await fetch('https://pump.fun/api/ipfs', {
method: 'POST',
body: formData
});
const result = await res.json();
console.log('β
Metadata uploaded:', result.metadataUri);
return result.metadataUri;
}
Step 2: Create Token with Dev Buy
async function createTokenWithDevBuy(privateKey, name, symbol, uri, buyAmountSol) {
const creator = Keypair.fromSecretKey(bs58.decode(privateKey));
const response = await fetch('https://pumpdev.io/api/create', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
publicKey: creator.publicKey.toBase58(),
name: name,
symbol: symbol,
uri: uri,
buyAmountSol: buyAmountSol,
slippage: 30,
jitoTip: 0.01,
priorityFee: 0.001
})
});
const result = await response.json();
console.log('π Mint address:', result.mint);
const mintKeypair = Keypair.fromSecretKey(bs58.decode(result.mintSecretKey));
const signedTxs = result.transactions.map((txInfo) => {
const tx = VersionedTransaction.deserialize(bs58.decode(txInfo.transaction));
const signers = txInfo.signers.includes('mint')
? [creator, mintKeypair]
: [creator];
tx.sign(signers);
return bs58.encode(tx.serialize());
});
await sendJitoBundle(signedTxs);
console.log(`β
Token created: https://pump.fun/${result.mint}`);
return result.mint;
}
π¦ Jito Bundles for Atomic Token Launches
One of the most powerful features is Jito bundle support:
β‘ Key Advantages:
- Create a token AND execute multiple buys in the same block
- Prevent front-running (no one can buy before your wallets)
- Ensure atomic execution (all transactions succeed or all fail)
Multi-Wallet Token Launch
async function createTokenWithMultipleBuyers(creatorKey, buyer1Key, buyer2Key, buyer3Key, uri) {
const creator = Keypair.fromSecretKey(bs58.decode(creatorKey));
const buyer1 = Keypair.fromSecretKey(bs58.decode(buyer1Key));
const buyer2 = Keypair.fromSecretKey(bs58.decode(buyer2Key));
const buyer3 = Keypair.fromSecretKey(bs58.decode(buyer3Key));
const wallets = { creator, buyer1, buyer2, buyer3 };
const response = await fetch('https://pumpdev.io/api/create-bundle', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
publicKey: creator.publicKey.toBase58(),
name: 'Bundle Launch Token',
symbol: 'BUNDLE',
uri: uri,
buyAmountSol: 0.5,
slippage: 30,
jitoTip: 0.02,
additionalBuyers: [
{ publicKey: buyer1.publicKey.toBase58(), amountSol: 1.0 },
{ publicKey: buyer2.publicKey.toBase58(), amountSol: 0.5 },
{ publicKey: buyer3.publicKey.toBase58(), amountSol: 0.3 }
]
})
});
const result = await response.json();
const mintKeypair = Keypair.fromSecretKey(bs58.decode(result.mintSecretKey));
const signedTxs = result.transactions.map((txInfo) => {
const tx = VersionedTransaction.deserialize(bs58.decode(txInfo.transaction));
const signers = txInfo.signers
.map((s) => (s === 'mint' ? mintKeypair : wallets[s]))
.filter(Boolean);
tx.sign(signers);
return bs58.encode(tx.serialize());
});
await sendJitoBundle(signedTxs);
console.log(`π Token launched: https://pump.fun/${result.mint}`);
}
Sending Jito Bundles
const JITO_ENDPOINTS = [
'https://mainnet.block-engine.jito.wtf',
'https://amsterdam.mainnet.block-engine.jito.wtf',
'https://frankfurt.mainnet.block-engine.jito.wtf',
'https://ny.mainnet.block-engine.jito.wtf',
'https://tokyo.mainnet.block-engine.jito.wtf'
];
async function sendJitoBundle(signedTxs) {
for (const endpoint of JITO_ENDPOINTS) {
try {
const res = await fetch(`${endpoint}/api/v1/bundles`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'sendBundle',
params: [signedTxs]
})
});
const data = await res.json();
if (data.result) {
console.log('β
Bundle sent!');
console.log(`Bundle ID: ${data.result}`);
return { success: true, bundleId: data.result };
}
} catch (err) {
continue;
}
}
return { success: false };
}
π‘ Real-Time WebSocket Data
Stream live market data for free:
import WebSocket from 'ws';
const ws = new WebSocket('wss://pumpdev.io/ws');
ws.on('open', () => {
console.log('β
Connected to WebSocket');
// Subscribe to new token launches
ws.send(JSON.stringify({ method: 'subscribeNewToken' }));
// Subscribe to specific token trades
ws.send(JSON.stringify({
method: 'subscribeTokenTrade',
keys: ['TOKEN_MINT_1', 'TOKEN_MINT_2']
}));
// Track whale wallets
ws.send(JSON.stringify({
method: 'subscribeAccountTrade',
keys: ['WHALE_WALLET_ADDRESS']
}));
});
ws.on('message', (data) => {
const event = JSON.parse(data.toString());
if (event.txType === 'create') {
console.log(`π NEW: ${event.name} (${event.symbol})`);
console.log(` Mint: ${event.mint}`);
console.log(` Market Cap: ${event.marketCapSol?.toFixed(2)} SOL`);
}
if (event.txType === 'buy') {
console.log(`π BUY: +${event.solAmount} SOL`);
}
if (event.txType === 'sell') {
console.log(`π΄ SELL: -${event.solAmount} SOL`);
}
});
β‘ Advanced: Bundle Sell for Multiple Wallets
Sell from multiple wallets 3-4x faster with one API call:
async function sellBundleFast(mint, accounts, creatorPublicKey) {
const response = await fetch('https://pumpdev.io/api/trade-bundle', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
accounts: accounts.map(acc => ({
publicKey: acc.keypair.publicKey.toBase58(),
name: acc.name,
})),
action: 'sell',
mint: mint,
amount: '100%',
slippage: 99,
priorityFee: 0.005,
jitoTip: 0.01,
creator: creatorPublicKey
})
});
const result = await response.json();
console.log(`Built ${result.stats.success}/${result.stats.total} in ${result.stats.durationMs}ms`);
const signedTxs = [];
for (const txInfo of result.transactions) {
if (!txInfo.transaction) continue;
const account = accounts.find(a => a.name === txInfo.name);
const tx = VersionedTransaction.deserialize(bs58.decode(txInfo.transaction));
tx.sign([account.keypair]);
signedTxs.push(bs58.encode(tx.serialize()));
}
await sendJitoBundle(signedTxs);
}
π Performance Comparison
| Method | 4 Accounts | HTTP Calls |
|---|---|---|
| Individual calls | ~800ms | 4 |
| Bundle API | ~150ms | 1 |
| Speedup | 5x faster | 75% less |
π Conclusion & Next Steps
The pump.fun API enables you to build:
- π Token launchers β Automate token creation
- π€ Trading bots β Execute buy/sell strategies
- π― Sniper bots β React to new launches instantly
- π¦ Bundle systems β Atomic multi-wallet purchases
- π Analytics β Stream real-time market data
Get Started
- π Website: pumpdev.io
- π Docs: pumpdev.io/welcome
- π¬ Telegram: t.me/pumpdev_io
- π¦ Twitter: @PumpDevIO
Happy coding! If you found this guide helpful, please leave a reaction and share it with other Solana developers. Got questions? Drop them in the comments below! π
Top comments (0)