Registry / analytics / iobroker.mempool-space

iobroker.mempool-space

JSON →
library0.0.4jsnpmunverified

ioBroker adapter v0.0.4 for real-time Bitcoin network data via mempool.space WebSocket API. Provides live data on blocks, fees, network statistics, price conversions (USD/EUR), and mempool status. Requires Node >= 18 and an ioBroker installation. Uses WebSocket connections to stream data. Minimal configuration: just set WS URL (default wss://mempool.space/api/v1/ws). Created by Hans-Wurst-21. Early release with monthly updates.

npm install iobroker.mempool-space
INSTALL
IMPORT
SIG · IOBROKER.MEMPOOL-S
I
iobroker.mempool-space
analyticsjavascriptv0.0.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

adapter
import * as utils from '@iobroker/adapter-core';
const utils = require('@iobroker/adapter-core');
Use ESM imports for adapter-core to ensure proper loading.
WebSocket
import WebSocket from 'ws';
const WebSocket = require('ws').WebSocket;
ws package provides a default export; named import is incorrect.
AdapterClass
import { Adapter } from '@iobroker/adapter-core';
const { Adapter } = require('@iobroker/adapter-core');
iobroker.js-controller exports Adapter as named export. Use ES module syntax for proper tree shaking.

Shows how to create an ioBroker adapter with WebSocket connection to mempool.space, handling real-time data for conversions, fees, blocks, stats, and mempool.

import * as utils from '@iobroker/adapter-core'; import WebSocket from 'ws'; class MempoolSpace extends utils.Adapter { constructor(options) { super({ ...options, name: 'mempool-space', }); this.on('ready', this.onReady.bind(this)); } async onReady() { // Use user-provided URL or default const wsUrl = this.config.wsUrl || 'wss://mempool.space/api/v1/ws'; const ws = new WebSocket(wsUrl); ws.on('open', () => { this.log.info('Connected to mempool.space WebSocket'); this.setState('info.connection', true, true); }); ws.on('message', (data) => { const parsed = JSON.parse(data.toString()); // Handle 'conversions', 'fees', 'blocks', 'stats', 'mempool' actions switch (parsed.action) { case 'conversions': this.setState('conversion.usd', parsed.data.usd, true); this.setState('conversion.eur', parsed.data.eur, true); this.setState('conversion.moscowtimeUSD', parsed.data.moscowtimeUSD, true); this.setState('conversion.moscowtimeEUR', parsed.data.moscowtimeEUR, true); this.setState('conversion.timestamp', parsed.data.timestamp, true); break; case 'fees': this.setState('fees.fastest', parsed.data.fastestFee, true); this.setState('fees.halfHour', parsed.data.halfHourFee, true); this.setState('fees.hour', parsed.data.hourFee, true); this.setState('fees.economy', parsed.data.economyFee, true); this.setState('fees.minimum', parsed.data.minimumFee, true); break; case 'blocks': this.setState('block.height', parsed.data.height, true); this.setState('block.hash', parsed.data.hash, true); this.setState('block.timestamp', parsed.data.timestamp, true); this.setState('block.miningPool', parsed.data.miningPool, true); break; case 'stats': this.setState('network.averageBlockTime', parsed.data.averageBlockTime, true); this.setState('network.difficultyChange', parsed.data.difficultyChange, true); this.setState('network.previousDifficultyChange', parsed.data.previousDifficultyChange, true); break; case 'mempool': this.setState('mempool.transactionCount', parsed.data.count, true); break; default: this.log.warn(`Unknown action: ${parsed.action}`); } }); ws.on('close', () => { this.setState('info.connection', false, true); this.log.info('WebSocket disconnected'); }); ws.on('error', (err) => { this.log.error(`WebSocket error: ${err.message}`); }); } } // @ts-ignore if (require.main !== module) { module.exports = (options) => new MempoolSpace(options); }
Debug
Known issues
breakingNode.js >= 18 required. Adapter will fail to start on older versions.
fix
Upgrade Node.js to version 18 or higher.
affects: 0.0.x
gotchaWebSocket URL default is wss://mempool.space/api/v1/ws; using public instance may throttle or require API key.
fix
Set up a local mempool.space instance for production use.
affects: >=0.0.1
gotchaData may take several minutes to populate; adapter waits for at least 2 new blocks before showing all states.
fix
Be patient; data arrives after blocks are mined.
affects: 0.0.x
deprecatedThe adapter uses 'connectionn' state (double n) which may be renamed in future versions.
fix
Check for 'info.connection' (correct spelling) in state handling.
affects: 0.0.x
gotchaWebSocket connection may drop; adapter does not automatically reconnect.
fix
Implement reconnection logic or wait for adapter restart.
affects: 0.0.x
Errors
Common errors & fixes
Error: Cannot find module 'ws'
Missing ws dependency; npm install without --production should include it.
fix
Run 'npm install' in the adapter directory.
TypeError: utils.Adapter is not a constructor
Incorrect import of adapter-core; trying to use default export instead of named.
fix
Use 'import * as utils from '@iobroker/adapter-core';' and then 'new utils.Adapter(...)'.
WebSocket connection to 'wss://mempool.space/api/v1/ws' failed: Connection refused
mempool.space server may be down or blocking the IP.
fix
Check your internet connection and try a different mempool.space instance.
Upgrade
Version history
0.0.4latest on npm
Audit
Dependencies
iobroker.js-controllerrequiredRequired ioBroker runtime
wsrequiredWebSocket client for mempool.space connection
Agent activity
26 hits · last 30 days
node
24
OpenAI (training)
1
Resources
iobroker.mempool-space — npm install iobroker.mempool-space · libregistry