<p>Endpoint</p>
<p>wss://mempool.space/api/v1/ws</p>
<p>Description:</p>
<p>Default push: { action: 'want', data: ['blocks', ...] } to express what you want pushed. Available: blocks, mempool-blocks, live-2h-chart, and stats.</p>
<p>Push transactions related to address:</p>
<p>{ 'track-address': '3PbJ...bF9B' } to receive all new transactions containing that address as input or output. Returns an array of transactions. address-transactions for new mempool transactions, and block-transactions for new block confirmed transactions.</p>
<pre><code>Common JS
</code></pre>
<p>Code Example
GitHub Repo</p>
<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;script src=&quot;https://mempool.space/mempool.js&quot;&gt;&lt;/script&gt;
    &lt;script&gt;
      const init = async () =&gt; {
        
  const { bitcoin: { websocket } } = mempoolJS({
          hostname: 'mempool.space'
        });

  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(&quot;result-blocks&quot;).textContent = JSON.stringify(res.block, undefined, 2);
    }
    if (res.mempoolInfo) {
      document.getElementById(&quot;result-mempool-info&quot;).textContent = JSON.stringify(res.mempoolInfo, undefined, 2);
    }
    if (res.transactions) {
      document.getElementById(&quot;result-transactions&quot;).textContent = JSON.stringify(res.transactions, undefined, 2);
    }
    if (res[&quot;mempool-blocks&quot;]) {
      document.getElementById(&quot;result-mempool-blocks&quot;).textContent = JSON.stringify(res[&quot;mempool-blocks&quot;], undefined, 2);
    }
  });
  
      };
      init();
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;h2&gt;Blocks&lt;/h2&gt;&lt;pre id=&quot;result-blocks&quot;&gt;Waiting for data&lt;/pre&gt;&lt;br&gt;
    &lt;h2&gt;Mempool Info&lt;/h2&gt;&lt;pre id=&quot;result-mempool-info&quot;&gt;Waiting for data&lt;/pre&gt;&lt;br&gt;
    &lt;h2&gt;Transactions&lt;/h2&gt;&lt;pre id=&quot;result-transactions&quot;&gt;Waiting for data&lt;/pre&gt;&lt;br&gt;
    &lt;h2&gt;Mempool Blocks&lt;/h2&gt;&lt;pre id=&quot;result-mempool-blocks&quot;&gt;Waiting for data&lt;/pre&gt;&lt;br&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>Or ES Module</p>
<p>Install Package
GitHub RepoNPM Package</p>
<pre><code># npm
npm install @mempool/mempool.js --save

# yarn
yarn add @mempool/mempool.js
</code></pre>
<p>Code Example</p>
<pre><code>import mempoolJS from &quot;@mempool/mempool.js&quot;;

const init = async () =&gt; {
  
const { bitcoin: { websocket } } = mempoolJS({
    hostname: 'mempool.space'
  });

const ws = websocket.initServer({
options: [&quot;blocks&quot;, &quot;stats&quot;, &quot;mempool-blocks&quot;, &quot;live-2h-chart&quot;],
});

ws.on(&quot;message&quot;, function incoming(data) {
const res = JSON.parse(data.toString());
if (res.block) {
console.log(res.block);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res[&quot;mempool-blocks&quot;]) {
console.log(res[&quot;mempool-blocks&quot;]);
}
});
    
};
init();
</code></pre>

CC BY-SA 4.0
2022-06-12T22:09:11.850Z
2022-06-12T22:15:36.023Z
2022-06-12T22:15:36.023Z
Alfhilðr ínn Seiðkona
<p>I would like to know if I could monitor new transactions on several addresses that I do not have access to personally and see if the transactions were validated by the network with an API, and if possible to use WebSockets which is very interesting compared to REST APIs.</p>
<p>I have seen the API offer of blockcypher and blockchain.com that meets my request but I wanted to know if there was simpler.</p>
<p>Thanks for your future answers</p>

<transactions>
Monitor multiple bitcoin addresses
Sly
# Monitor multiple bitcoin addresses

(Asked by: username_0 on 2022-06-09)

I would like to know if I could monitor new transactions on several addresses that I do not have access to personally and see if the transactions were validated by the network with an API, and if possible to use WebSockets which is very interesting compared to REST APIs.

I have seen the API offer of blockcypher and blockchain.com that meets my request but I wanted to know if there was simpler.

Thanks for your future answers

**Tags:** transactions


---

## 1 answers

### Answer by username_1 on 2022-06-12. Score: 2

Endpoint
wss://mempool.space/api/v1/ws
Description:
Default push: { action: 'want', data: ['blocks', ...] } to express what you want pushed. Available: blocks, mempool-blocks, live-2h-chart, and stats.
Push transactions related to address:
{ 'track-address': '3PbJ...bF9B' } to receive all new transactions containing that address as input or output. Returns an array of transactions. address-transactions for new mempool transactions, and block-transactions for new block confirmed transactions.
Common JS

Code Example
GitHub Repo


  
    
    
  
  
    BlocksWaiting for data
    Mempool InfoWaiting for data
    TransactionsWaiting for data
    Mempool BlocksWaiting for data
  


Or ES Module
Install Package
GitHub RepoNPM Package
# npm
npm install @mempool/mempool.js --save

# yarn
yarn add @mempool/mempool.js

Code Example
import mempoolJS from "@mempool/mempool.js";

const init = async () => {
  
const { bitcoin: { websocket } } = mempoolJS({
    hostname: 'mempool.space'
  });

const ws = websocket.initServer({
options: ["blocks", "stats", "mempool-blocks", "live-2h-chart"],
});

ws.on("message", function incoming(data) {
const res = JSON.parse(data.toString());
if (res.block) {
console.log(res.block);
}
if (res.mempoolInfo) {
console.log(res.mempoolInfo);
}
if (res.transactions) {
console.log(res.transactions);
}
if (res["mempool-blocks"]) {
console.log(res["mempool-blocks"]);
}
});
    
};
init();


---

