<p>You need to build  Bitcoin protocol messages.
This Python library can help you do it, some example here:</p>
<p><a href="https://github.com/petertodd/python-bitcoinlib/tree/master/examples" rel="nofollow noreferrer">https://github.com/petertodd/python-bitcoinlib/tree/master/examples</a></p>

CC BY-SA 4.0
2023-05-31T17:44:03.293Z
2023-05-31T17:44:19.833Z
2023-05-31T17:44:19.833Z
st3b1t
<p>Excellent question, and welcome to the community!</p>
<h3>Short Answer</h3>
<p>Maybe.</p>
<h3>Long answer</h3>
<p>Yes, you can send queries to other nodes on the Bitcoin network. Note that these aren't RPC calls, but <a href="https://en.bitcoin.it/wiki/Protocol_specification" rel="nofollow noreferrer">Bitcoin's underlying communication protocol</a>. That means that all of the calls will be a little different, and some of them won't exist.</p>
<p>Examples:</p>
<ul>
<li><p>There's no equivalent to <code>getblockcount</code> in the underlying protocol. Instead, you can connect to a node and listen for its <code>version</code> message, and look at the start_height field.</p>
</li>
<li><p>Instead of <code>getrawmempool</code>, you use <code>mempool</code>.</p>
</li>
<li><p>Instead of <code>getpeerinfo</code>, you use <code>getaddr</code>.</p>
</li>
<li><p>There's no equivalent to <code>stop</code>, because that would be stupid.</p>
</li>
</ul>
<p>Also, if you're trying to query other nodes on the network, one of these libraries will be very helpful:</p>
<ul>
<li>Python: <a href="http://protocoin.readthedocs.org/en/v0.1/index.html" rel="nofollow noreferrer">http://protocoin.readthedocs.org/en/v0.1/index.html</a><br />
(Use protocoin.clients.BitcoinClient)</li>
<li>Java: <a href="https://bitcoinj.github.io/" rel="nofollow noreferrer">https://bitcoinj.github.io/</a><br />
(Use Peer.sendMessge)</li>
<li>Go: <a href="https://github.com/btcsuite/btcd/blob/master/wire/README.md" rel="nofollow noreferrer">https://github.com/btcsuite/btcd/blob/master/wire/README.md</a></li>
</ul>
<p>(If you're not using one of these languages, leave a comment.)</p>

CC BY-SA 3.0
2017-06-28T08:25:26.067Z
Is there an API library for PHP?
Jacek Krysztofik
CC BY-SA 3.0
2017-06-28T19:53:53.823Z
@rishta Don't think so. Didn't find any while googling.
Nick ODell
CC BY-SA 3.0
2014-10-12T16:37:48.467Z
2017-06-28T19:53:40.370Z
2020-06-16T11:10:03.350Z
Nick ODell
<p>I know how to query the blockchain stored on my machine programmatically using bitcoind commands. Is it possible to do the same on a public node?</p>

<p>For example, is it possible to send “getblockcount” over the internet to bitcoinstats.com, hard-coded in the bitcoin source, or to inductivesoul.us, found in the bitcoin.it wiki? What are the steps to do so?</p>

<p>Edit</p>

<p>The quick answer is:</p>

<ul>
<li>No, you cannot use bitcoind commands.</li>
<li>You have to communicate with a remote node using TCP.</li>
<li>You have to use a different set of commands found in the Protocol Specification.</li>
</ul>

<protocol><json-rpc>
How do I query a remote bitcoin node like RPC?
u2843
# How do I query a remote bitcoin node like RPC?

(Asked by: username_0 on 2014-10-12)

I know how to query the blockchain stored on my machine programmatically using bitcoind commands. Is it possible to do the same on a public node?

For example, is it possible to send “getblockcount” over the internet to bitcoinstats.com, hard-coded in the bitcoin source, or to inductivesoul.us, found in the bitcoin.it wiki? What are the steps to do so?

Edit

The quick answer is:

* No, you cannot use bitcoind commands.
* You have to communicate with a remote node using TCP.
* You have to use a different set of commands found in the Protocol Specification.

**Tags:** protocol, json-rpc


---

## 2 answers

### Answer by username_2 on 2014-10-12. Score: 6 | Accepted answer

Excellent question, and welcome to the community!

### Short Answer

Maybe.

### Long answer

Yes, you can send queries to other nodes on the Bitcoin network. Note that these aren't RPC calls, but [Bitcoin's underlying communication protocol](https://en.bitcoin.it/wiki/Protocol_specification). That means that all of the calls will be a little different, and some of them won't exist.

Examples:

* There's no equivalent to `getblockcount` in the underlying protocol. Instead, you can connect to a node and listen for its `version` message, and look at the start\_height field.
* Instead of `getrawmempool`, you use `mempool`.
* Instead of `getpeerinfo`, you use `getaddr`.
* There's no equivalent to `stop`, because that would be stupid.

Also, if you're trying to query other nodes on the network, one of these libraries will be very helpful:

* Python: <http://protocoin.readthedocs.org/en/v0.1/index.html>  
  (Use protocoin.clients.BitcoinClient)
* Java: <https://bitcoinj.github.io/>  
  (Use Peer.sendMessge)
* Go: <https://github.com/btcsuite/btcd/blob/master/wire/README.md>

(If you're not using one of these languages, leave a comment.)

> **Comments:**
> **username_3**: Is there an API library for PHP?  
> **username_2**: @rishta Don't think so. Didn't find any while googling.  

---

### Answer by username_1 on 2023-05-31. Score: 1

You need to build Bitcoin protocol messages.
This Python library can help you do it, some example here:

<https://github.com/petertodd/python-bitcoinlib/tree/master/examples>


---

