Skip to main content

Connection

Connect to the WebSocket server at wss://<region>.raze.sh/ws/sol with your API key as a query parameter. Available regions: de.raze.sh, us.raze.sh, jp.raze.sh

JavaScript

Subscribe to Event Types

Listen for all deploys, trades, and alerts in real time.
const WebSocket = require("ws");

const API_KEY = "sk_your_api_key";
const ws = new WebSocket(`wss://de.raze.sh/ws/sol?apiKey=${API_KEY}`);

ws.on("open", () => {
  console.log("Connected");

  // Subscribe to event types
  ws.send(JSON.stringify({
    action: "subscribe",
    subscriptions: ["trade", "deploy", "alert"]
  }));
});

ws.on("message", (data) => {
  const msg = JSON.parse(data.toString());

  switch (msg.type) {
    case "welcome":
      console.log("Authenticated:", msg.authenticated);
      break;
    case "event_subscription_confirmed":
      console.log("Subscribed to:", msg.event_types);
      break;
    case "trade":
      console.log(`${msg.data.type} ${msg.data.mint}${msg.data.solAmount} SOL`);
      break;
    case "deploy":
      console.log(`New token: ${msg.data.name} (${msg.data.symbol}) on ${msg.data.platform}`);
      break;
    case "alert":
      console.log(`Alert: ${msg.data.mint}${msg.data.tradeCount} trades, ${msg.data.totalVolumeSol} SOL`);
      break;
    case "error":
      console.error(`Error [${msg.code}]: ${msg.error}`);
      break;
  }
});

ws.on("close", () => console.log("Disconnected"));
ws.on("error", (err) => console.error("WebSocket error:", err));

Subscribe to Specific Mints

Track trades for specific token mint addresses.
const WebSocket = require("ws");

const API_KEY = "sk_your_api_key";
const ws = new WebSocket(`wss://de.raze.sh/ws/sol?apiKey=${API_KEY}`);

ws.on("open", () => {
  // Subscribe to specific token mints
  ws.send(JSON.stringify({
    action: "subscribe",
    mints: [
      "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
      "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
    ]
  }));
});

ws.on("message", (data) => {
  const msg = JSON.parse(data.toString());

  if (msg.type === "subscription_confirmed") {
    console.log(`Tracking ${msg.total_subscriptions} mint(s)`);
  }

  if (msg.type === "trade") {
    const t = msg.data;
    const price = msg.priceInfo?.solPrice
      ? `($${(t.solAmount * msg.priceInfo.solPrice).toFixed(2)})`
      : "";
    console.log(`${t.type} ${t.solAmount} SOL ${price}${t.mint}`);
  }
});

Subscribe to Wallet Signers

Track all trades from specific wallets.
const WebSocket = require("ws");

const API_KEY = "sk_your_api_key";
const ws = new WebSocket(`wss://de.raze.sh/ws/sol?apiKey=${API_KEY}`);

ws.on("open", () => {
  // Subscribe to wallet signers
  ws.send(JSON.stringify({
    action: "subscribe",
    signers: ["62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm"]
  }));
});

ws.on("message", (data) => {
  const msg = JSON.parse(data.toString());

  if (msg.type === "signer_subscription_confirmed") {
    console.log(`Tracking ${msg.total_signer_subscriptions} signer(s)`);
  }

  if (msg.type === "trade") {
    console.log(`${msg.data.signer} ${msg.data.type} ${msg.data.solAmount} SOL of ${msg.data.mint}`);
  }
});

Combined Subscription

Subscribe to mints, signers, and event types in a single message.
ws.send(JSON.stringify({
  action: "subscribe",
  mints: ["DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263"],
  signers: ["62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm"],
  subscriptions: ["deploy", "alert"]
}));

Keep-Alive Ping

Send periodic pings to keep the connection alive.
// Ping every 30 seconds
const pingInterval = setInterval(() => {
  if (ws.readyState === WebSocket.OPEN) {
    ws.send(JSON.stringify({ action: "ping" }));
  }
}, 30000);

ws.on("close", () => clearInterval(pingInterval));

Python

Subscribe to Event Types

import asyncio
import json
import websockets

API_KEY = "sk_your_api_key"
URI = f"wss://de.raze.sh/ws/sol?apiKey={API_KEY}"

async def stream_events():
    async with websockets.connect(URI) as ws:
        # Subscribe to event types
        await ws.send(json.dumps({
            "action": "subscribe",
            "subscriptions": ["trade", "deploy", "alert"]
        }))

        async for raw in ws:
            msg = json.loads(raw)

            if msg["type"] == "welcome":
                print(f"Connected — authenticated: {msg['authenticated']}")

            elif msg["type"] == "event_subscription_confirmed":
                print(f"Subscribed to: {msg['event_types']}")

            elif msg["type"] == "trade":
                d = msg["data"]
                print(f"{d['type']} {d['mint']}{d['solAmount']} SOL")

            elif msg["type"] == "deploy":
                d = msg["data"]
                print(f"New token: {d['name']} ({d['symbol']}) on {d['platform']}")

            elif msg["type"] == "alert":
                d = msg["data"]
                print(f"Alert: {d['mint']}{d['tradeCount']} trades, {d['totalVolumeSol']} SOL")

            elif msg["type"] == "error":
                print(f"Error [{msg.get('code')}]: {msg['error']}")

asyncio.run(stream_events())

Subscribe to Specific Mints

import asyncio
import json
import websockets

API_KEY = "sk_your_api_key"
URI = f"wss://de.raze.sh/ws/sol?apiKey={API_KEY}"

async def stream_mints():
    async with websockets.connect(URI) as ws:
        await ws.send(json.dumps({
            "action": "subscribe",
            "mints": [
                "DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263",
                "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
            ]
        }))

        async for raw in ws:
            msg = json.loads(raw)

            if msg["type"] == "subscription_confirmed":
                print(f"Tracking {msg['total_subscriptions']} mint(s)")

            elif msg["type"] == "trade":
                d = msg["data"]
                sol_price = msg.get("priceInfo", {}).get("solPrice")
                usd = f" (${d['solAmount'] * sol_price:.2f})" if sol_price else ""
                print(f"{d['type']} {d['solAmount']} SOL{usd}{d['mint']}")

asyncio.run(stream_mints())

Subscribe to Wallet Signers

import asyncio
import json
import websockets

API_KEY = "sk_your_api_key"
URI = f"wss://de.raze.sh/ws/sol?apiKey={API_KEY}"

async def stream_signers():
    async with websockets.connect(URI) as ws:
        await ws.send(json.dumps({
            "action": "subscribe",
            "signers": ["62ThHC1rs2GUfa8J4Qjcj5GD2MSL2d65pcJtenNieDnm"]
        }))

        async for raw in ws:
            msg = json.loads(raw)

            if msg["type"] == "signer_subscription_confirmed":
                print(f"Tracking {msg['total_signer_subscriptions']} signer(s)")

            elif msg["type"] == "trade":
                d = msg["data"]
                print(f"{d['signer']} {d['type']} {d['solAmount']} SOL of {d['mint']}")

asyncio.run(stream_signers())

With Reconnection Logic

import asyncio
import json
import websockets

API_KEY = "sk_your_api_key"
URI = f"wss://de.raze.sh/ws/sol?apiKey={API_KEY}"

async def stream_with_reconnect():
    while True:
        try:
            async with websockets.connect(URI) as ws:
                print("Connected")

                await ws.send(json.dumps({
                    "action": "subscribe",
                    "subscriptions": ["trade", "deploy"]
                }))

                # Start ping task
                async def ping_loop():
                    while True:
                        await asyncio.sleep(30)
                        await ws.send(json.dumps({"action": "ping"}))

                ping_task = asyncio.create_task(ping_loop())

                try:
                    async for raw in ws:
                        msg = json.loads(raw)
                        if msg["type"] == "pong":
                            continue
                        print(json.dumps(msg, indent=2))
                finally:
                    ping_task.cancel()

        except (websockets.ConnectionClosed, ConnectionError) as e:
            print(f"Disconnected: {e}. Reconnecting in 3s...")
            await asyncio.sleep(3)

asyncio.run(stream_with_reconnect())

Subscription Types

TypeDescription
tradeBuy/sell swap transactions
deployNew token deployments
migrationToken migrations (e.g. Pump.fun bonding curve graduation)
parsedRaw parsed transaction data from DEX parser
analysisBot detection (bundles, snipers)
alertHigh-activity alerts based on volume/trade metrics
rawRaw unprocessed transaction data

Server Messages

Message TypeWhen
welcomeOn successful connection
subscription_confirmedAfter subscribing to mints
signer_subscription_confirmedAfter subscribing to signers
event_subscription_confirmedAfter subscribing to event types
unsubscription_confirmedAfter unsubscribing from mints
signer_unsubscription_confirmedAfter unsubscribing from signers
event_unsubscription_confirmedAfter unsubscribing from event types
pongResponse to ping
errorOn invalid request or auth failure