import WebSocket from "ws";
//Open the websocket connection
const ws = new WebSocket("wss://api.pumplify.fun/data/live");
ws.on("open", function open() {
// Subscribing to new token events
let payload = {
event: "subscribeNewTokens",
};
ws.send(JSON.stringify(payload));
});
// Log the incoming messages
ws.on("message", function message(data) {
console.log(JSON.parse(data.toString()));
});
Migrations
Use the event subscribeMigrations to get completed migrations of pump.fun to raydium.
{
"event": "pumpMintUpdate",
"data": {
"mint": "ca of the token",
"marketCapUsd": 29722.379805964432,
"marketCapSol": 220.476076003,
"timestamp": 1741993140
}
}
Tutorial
import WebSocket from "ws";
//Open the websocket connection
const ws = new WebSocket("wss://api.pumplify.fun/data/live");
ws.on("open", function open() {
// Subscribing to market cap live
const payload = {
event: "subscribeMint",
data: {
mint: "ca here",
},
};
ws.send(JSON.stringify(payload));
});
// Log the incoming messages
ws.on("message", function message(data) {
console.log(JSON.parse(data.toString()));
});
Unsubscribing
We ask that you please unsubscribe to any subscriptions you no longer are using by sending the subscription request prefixed with un. For endpoints such as tokenUpdates, still provide the mint you want to unsubscribe from.
Example: unsubcribeNewTokens
Handling Multiple Subscriptions
Creating a new WebSocket for each subscription may result in you being banned for too many connections. To handle multiple subscriptions send multiple subscribe messages on the same connection. You can then filter the event to perform different actions. Please contact us if you were banned.
import WebSocket from "ws";
//Open the websocket connection
const ws = new WebSocket("wss://api.pumplify.fun/data/live");
ws.on("open", function open() {
// Subscribing to new token events
const payload1 = {
event: "subscribeNewTokens",
};
ws.send(JSON.stringify(payload1));
// Subscribing to migration events
const payload2 = {
event: "subscribeMigrations",
};
ws.send(JSON.stringify(payload2));
// Subscribing to token market cap
const payload3 = {
event: "subscribeMint",
data: {
mint: "ca here",
},
};
ws.send(JSON.stringify(payload3));
});
// Log the incoming messages
ws.on("message", function message(data) {
console.log(JSON.parse(data.toString()));
});