Skip to content

Block Monitoring

Overview

The Realtime API is a stateful, event-based API that communicates over a WebSocket. The WebSocket connection requires the following parameters:

  • URL: wss://api.bmining.pro/v1/block/latest
  • Headers:
    • Authorization: Bearer YOUR_API_KEY
Query Parameters
FieldTypeDescription
chainStringOptional. The blockchain to monitor.
tagStringOptional. The tag to monitor.
addressStringOptional. The address to monitor.

Below is a simple example using the popular ws library in Node.js to establish a socket connection, send a message from the client, and receive a response from the server. It requires that a valid API_KEY is exported in the system environment.

import WebSocket from "ws";
 
const url = "wss://api.bmining.pro/v1/block/latest?chain=bitcoin&tag=satoshi";
const ws = new WebSocket(url, {
  headers: {
    "Authorization": "Bearer " + process.env.API_KEY,
  },
});
 
ws.on("message", (message) => {
  console.log(JSON.parse(message.toString()));
});

Example

{
  "chain": "bitcoin",
  "block_height": 0,
  "block_hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
  "txns": [
    {
      "tx_hash": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
      "addresses": [
        "1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa"
      ]
    }
  ]
}