Skip to main content

PumpSwap Data API

Accessing PumpSwap data requires a PumpPortal API key and linked wallet funded with at least 0.02 SOL. By streaming PumpSwap data your wallet will incur a charge of 0.01 SOL for every 10000 websocket messages you receive.

PumpSwap data is enabled only if you connect to the websocket using the following URL format:

wss://pumpportal.fun/api/data?api-key=your-api-key-here

If the wallet linked to your API key does not contain the minimum balance of SOL, the connection will be restricted to only trades on the bonding curve.

Examples:

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 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": ["GkyPYa7NnCFbduLknCfBfP7p8564X1VZhwZYJ6CZpump"] # 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())

You can also unsubscribe from any data stream in the same way, using the following methods:

  • unsubscribeTokenTrade

  • unsubscribeAccountTrade