*Where "{YOUR-API-KEY}" is to be replaced with your API Key.
Getting Started
Setup API Configuration
Create a Mempool Node account, by clicking the "Register" button on the top right of our Dashboard, and complete the registration form.
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.
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.
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!
constWebSocket=require('websocket').client;constapiKey="YOUR-API-KEY"; // Replace with your actual API keyconstwsUrl=`wss://api.mempoolnode.com/ws?apiKey=${apiKey}`;constclient=newWebSocket();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);
import * as WebSocket from 'websocket';
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();
client.on('connect', (connection) => {
console.log('Connected to WebSocket');
connection.on('message', (message) => {
if (message.type === 'utf8') {
console.log(`Received data: ${message.utf8Data}`);
}
});
connection.on('close', () => {
console.log('WebSocket connection closed');
});
});
client.connect(wsUrl);
use async_tungstenite::tungstenite::protocol::Message;
use futures_util::stream::StreamExt;
use std::error::Error;
use async_tungstenite::tokio::connect_async;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let api_key = "YOUR-API-KEY"; // Replace with your actual API key
let ws_url = format!("wss://api.mempoolnode.com/ws?apiKey={}", api_key);
let (ws_stream, _) = connect_async(ws_url).await?;
let (mut write_stream, mut read_stream) = ws_stream.split();
while let Some(Ok(msg)) = read_stream.next().await {
if let Message::Text(data) = msg {
println!("Received data: {}", data);
}
}
Ok(())
}
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
import java.net.URI;
import java.net.URISyntaxException;
public class WebSocketExample {
public static void main(String[] args) throws URISyntaxException {
String apiKey = "YOUR-API-KEY"; // Replace with your actual API key
String wsUrl = "wss://api.mempoolnode.com/ws?apiKey=" + apiKey;
WebSocketClient client = new WebSocketClient(new URI(wsUrl)) {
@Override
public void onOpen(ServerHandshake serverHandshake) {
System.out.println("Connected to WebSocket");
}
@Override
public void onMessage(String message) {
System.out.println("Received data: " + message);
}
@Override
public void onClose(int code, String reason, boolean remote) {
System.out.println("WebSocket connection closed");
}
@Override
public void onError(Exception e) {
e.printStackTrace();
}
};
client.connect();
}
}
import asyncioimport websocketsasyncdefconnect_to_websocket(): api_key ="YOUR-API-KEY"# Replace with your actual API key ws_url =f"wss://api.mempoolnode.com/ws?apiKey={api_key}"asyncwith websockets.connect(ws_url)as websocket:whileTrue:# Receive and process data from the WebSocket server as needed data =await websocket.recv()print(f"Received data: {data}")if__name__=="__main__": asyncio.get_event_loop().run_until_complete(connect_to_websocket())TypeScript
usingSystem;usingWebSocketSharp;classProgram{staticvoidMain(string[] args) {string apiKey ="YOUR-API-KEY"; // Replace with your actual API keystring wsUrl =$"wss://api.mempoolnode.com/ws?apiKey={apiKey}";using (var ws =newWebSocket(wsUrl)) {ws.OnMessage+= (sender, e) => {if (e.IsText) {Console.WriteLine($"Received data: {e.Data}"); } };ws.OnError+= (sender, e) => {Console.WriteLine($"WebSocket error: {e.Message}"); };ws.OnClose+= (sender, e) => {Console.WriteLine("WebSocket connection closed"); };ws.Connect();Console.WriteLine("Connected to WebSocket");Console.ReadLine(); // Keep the application running } }}