Connect via Web Socket

Connect to Mempool Node's mempool monitoring services with web sockets.

Good to know: All mempool data are sent as a JSON payload, you must use the following ws address with your API Key appended to connect:

wss://api.mempoolnode.com/ws?apiKey={YOUR-API-KEY}

*Where "{YOUR-API-KEY}" is to be replaced with your API Key.

Getting Started

Setup API Configuration

  1. Create a Mempool Node account, by clicking the "Register" button on the top right of our Dashboard, and complete the registration form.

  2. Mempool Node will create an API Key named "Mempool Key 1" for your account, that you can configure to use. You can create additional API keys from your Dashboard by clicking the "+" button at the top right of Mempool Key 1.

Add API Configuration Key

Configure Web Socket

Configure a new web socket for your API configuration by toggling the "Webhook/Web Socket" to "Web Socket" and then clicking "â‹®" next to the On/Off toggle on the right, and selecting "Configure". This will open a form, in which you populate your webhook specifics: Whitelist Addresses, Blockchain(Currently Ethereum & Binance Smart Chain are supported) & Watched Addresses. Once completed, click the green "Save" button.

Web Socket Configuration Form for API Mempool Key

Add Whitelist Addresses

By default there is a field available for you to enter a valid IP or URL address to whitelist, however, to add an additional address to whitelist click the "+" on the right of "Whitelist Addresses" and enter the address you wish to whitelist. Once completed, click the green "Save" button.

Add Address to Watch

By default there is a field available for you to enter an address to watch, however, to add an additional address to watch click the "+" on the right of "Watched Addresses" and enter the address you wish to watch. Once completed, click the green "Save" button.

Ethereum & Binance Smart Chain addresses start with "0x" followed by 40 characters. Any valid ETH or BSC address will be accepted, this also includes external accounts and smart contract addresses.

To stop watching a specific address entered, you can click the trash/bin icon next to the address, and once saved, you'll no longer watch that address. Once completed, click the green "Save" button.

Start Receiving Data via Web Socket

Now that everything is configured, all you have to do is toggle the On/Off switch for the specific Mempool API Key you wish to start receiving data, and your mempool data will begin to fly in. Viola!

Toggle On Web Socket

Examples in Javascript, Rust, TypeScript, Java, , C++, Python & C#

const WebSocket = require('websocket').client;

const apiKey = "YOUR-API-KEY"; // Replace with your actual API key
const wsUrl = `wss://api.mempoolnode.com/ws?apiKey=${apiKey}`;

const client = new WebSocket();

client.on('connectFailed', (error) => {
    console.error(`Connection error: ${error.toString()}`);
});

client.on('connect', (connection) => {
    console.log('Connected to WebSocket');

    connection.on('error', (error) => {
        console.error(`Connection error: ${error.toString()}`);
    });

    connection.on('close', () => {
        console.log('Connection closed');
    });

    connection.on('message', (message) => {
        if (message.type === 'utf8') {
            console.log(`Received data: ${message.utf8Data}`);
        }
    });
});

client.connect(wsUrl);

Last updated