Real-time Pump.fun Data
Stream real-time token creation, migration, and trading data on Pump.fun and PumpSwap by connecting to the PumpPortal Websocket at wss://pumpportal.fun/api/data?api-key=your-api-key-here.
Once you connect, you can subscribe to different data streams. The following methods are available:
-
subscribeNewTokenFor token creation events. (Free) -
subscribeMigrationFor subscribing to token migration events. (Free) -
subscribeTokenTradeFor all trades made on specific token(s). (Metered at 0.01 SOL per 10000 events) -
subscribeAccountTradeFor all trades made by specific account(s). (Metered at 0.01 SOL per 10000 events)
Subscribing to tokens or accounts requires a PumpPortal API key and linked wallet funded with at least 0.02 SOL. By streaming buy/sell events your wallet will incur a charge of 0.01 SOL for every 10000 websocket messages you receive.
You should NOT open a new Websocket connection for every token or account you subscribe to. Instead, you should send any new subscribe messages to the same connection. Clients that repeatedly attempt to open many websocket connections at once may be timed out. Bans expire every hour, so if you accidentally get banned you can fix your code and connect again soon. For detailed rate limit information read here.
Examples:
- Python
- JavaScript
import asyncio
import websockets
import json
async def subscribe():
uri = "wss://pumpportal.fun/api/data?api-key=your-api-key-here"
async with websockets.connect(uri) as websocket:
# Subscribing to token creation events
payload = {
"method": "subscribeNewToken",
}
await websocket.send(json.dumps(payload))
# Subscribing to migration events
payload = {
"method": "subscribeMigration",
}
await websocket.send(json.dumps(payload))
# Subscribing to trades made by accounts
payload = {
"method": "subscribeAccountTrade",
"keys": ["AArPXm8JatJiuyEffuC1un2Sc835SULa4uQqDcaGpAjV"] # array of accounts to watch
}
await websocket.send(json.dumps(payload))
# Subscribing to trades on tokens
payload = {
"method": "subscribeTokenTrade",
"keys": ["91WNez8D22NwBssQbkzjy4s2ipFrzpmn5hfvWVe2aY5p"] # array of token CAs to watch
}
await websocket.send(json.dumps(payload))
async for message in websocket:
print(json.loads(message))
# Run the subscribe function
asyncio.get_event_loop().run_until_complete(subscribe())
import WebSocket from 'ws';
const ws = new WebSocket('wss://pumpportal.fun/api/data?api-key=your-api-key-here');
ws.on('open', function open() {
// Subscribing to token creation events
let payload = {
method: "subscribeNewToken",
}
ws.send(JSON.stringify(payload));
// Subscribing to migration events
let payload = {
method: "subscribeMigration",
}
ws.send(JSON.stringify(payload));
// Subscribing to trades made by accounts
payload = {
method: "subscribeAccountTrade",
keys: ["AArPXm8JatJiuyEffuC1un2Sc835SULa4uQqDcaGpAjV"] // array of accounts to watch
}
ws.send(JSON.stringify(payload));
// Subscribing to trades on tokens
payload = {
method: "subscribeTokenTrade",
keys: ["91WNez8D22NwBssQbkzjy4s2ipFrzpmn5hfvWVe2aY5p"] // array of token CAs to watch
}
ws.send(JSON.stringify(payload));
});
ws.on('message', function message(data) {
console.log(JSON.parse(data));
});
You can also unsubscribe from any data stream in the same way, using the following methods:
-
unsubscribeNewToken -
unsubscribeTokenTrade -
unsubscribeAccountTrade
- Python
- JavaScript
import asyncio
import websockets
import json
async def subscribe():
uri = "wss://pumpportal.fun/api/data?api-key=your-api-key-here"
async with websockets.connect(uri) as websocket:
# Subscribing to token creation events
payload = {
"method": "subscribeNewToken",
}
await websocket.send(json.dumps(payload))
# Unsubscribing from new token events
payload = {
"method": "unsubscribeNewToken",
}
await websocket.send(json.dumps(payload))
async for message in websocket:
print(json.loads(message))
# Run the subscribe function
asyncio.get_event_loop().run_until_complete(subscribe())
const ws = new WebSocket(`wss://pumpportal.fun/api/data?api-key=your-api-key-here`);
ws.on('open', function open() {
ws.send(JSON.stringify({
method: "subscribeTokenTrade",
keys: ["Bwc4EBE65qXVzZ9ZiieBraj9GZL4Y2d7NN7B9pXENWR2"]
}));
// unsubscribe after 10 seconds
setTimeout(()=>{
ws.send(JSON.stringify({
method: "unsubscribeTokenTrade",
keys: ["Bwc4EBE65qXVzZ9ZiieBraj9GZL4Y2d7NN7B9pXENWR2"]
}));
}, 10000);
});