Dokumentation
Endpunkt
wss://mempool.emzy.de/api/v1/ws Beschreibung
Standard Senden:
Sende Transaktionen bezogen auf die Adresse:
{ action: 'want', data: ['blocks', ...] }
um auszudrücken, was gepusht werden soll. Verfügbar: blocks
, mempool-blocks
, live-2h-chart
, und stats
.Sende Transaktionen bezogen auf die Adresse:
{ 'track-address': '3PbJ...bF9B' }
um alle neuen Transaktionen mit der Adresse als Input oder Output enthalten zu empfangen. Gibt Array von Tansaktionen zurück. address-transactions
für neue Mempool-Transaktionen, und block-transactions
Codebeispiel
<!DOCTYPE html>
<html>
<head>
<script src="https://mempool.space/mempool.js"></script>
<script>
const init = async () => {
const { bitcoin: { websocket } } = mempoolJS({
hostname: 'mempool.emzy.de'
});
const ws = websocket.initClient({
options: ['blocks', 'stats', 'mempool-blocks', 'live-2h-chart'],
});
ws.addEventListener('message', function incoming({data}) {
const res = JSON.parse(data.toString());
if (res.block) {
document.getElementById("result-blocks").textContent = JSON.stringify(res.block, undefined, 2);
}
if (res.mempoolInfo) {
document.getElementById("result-mempool-info").textContent = JSON.stringify(res.mempoolInfo, undefined, 2);
}
if (res.transactions) {
document.getElementById("result-transactions").textContent = JSON.stringify(res.transactions, undefined, 2);
}
if (res["mempool-blocks"]) {
document.getElementById("result-mempool-blocks").textContent = JSON.stringify(res["mempool-blocks"], undefined, 2);
}
});
};
init();
</script>
</head>
<body>
<h2>Blocks</h2><pre id="result-blocks">Waiting for data</pre><br>
<h2>Mempool Info</h2><pre id="result-mempool-info">Waiting for data</pre><br>
<h2>Transactions</h2><pre id="result-transactions">Waiting for data</pre><br>
<h2>Mempool Blocks</h2><pre id="result-mempool-blocks">Waiting for data</pre><br>
</body>
</html>