<p>There are several ways depending on what you are using.  If you are wanting to query the daemon - one must assume you are running a Linux box or VPS</p>

<p>You do not want or need an " address balance " - you need YOUR wallet balance</p>

<p>This question has already been partially answered here =>  <a href="https://bitcoin.stackexchange.com/questions/44373/how-would-one-monitor-an-address-for-a-transaction-and-1-confirmation-in-php/44398#44398">How would one monitor an address for a transaction and 1 confirmation in PHP?</a></p>

<p>The best way however is to use what the Electrum docs recommend - a curl call like this =>  <code>curl --data-binary '{"id":"curltext","method":"getbalance","params":{"funded":true}}' http://127.0.0.1:7777</code></p>

<p>If you are using PHP - it would look something like this:</p>

<pre><code>$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:7777");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"id\":\"curltext\",\"method\":\"getbalance\",\"params\":{\"funded\":true}}");
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);
</code></pre>

<p>You could make this inside a try-catch and trigger it by a cron job running at whatever interval you want to check</p>

<p>What comes back is a JSON-RPC file which you can decode into an array</p>

<pre><code>$result =  json_decode($response, true);
</code></pre>

<p>and plug that into another variable for the single thing or things you want to work on from there</p>

<pre><code>$wanted = $result["result"]["xxxxxxxxx"];
</code></pre>

<p>any of the parameters can be passed as a variable to the curl call</p>

<p>for instance to add a request it would go like this:</p>

<pre><code>curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"id\":\"curltext\",\"method\":\"addrequest\",\"params\":{\"amount\":\"$how_much\",\"memo\":\"$your_memo-&gt;some_data_field\"}}");
</code></pre>

<p>You just need to run a  "getbalance " - or any - command see what it returns and adjust your code to pull the returned value from "result" - you just test for a greater than " 0 " and then empty the wallet by sending it to another wallet and wait for the next payment</p>

<p>You could then use that data to trigger a "do something" like the email example in the above link from the middle example there.</p>

CC BY-SA 4.0
2017-09-01T01:21:42.170Z
2019-06-12T22:18:32.640Z
2019-06-12T22:18:32.640Z
wilburunion
<p>Just found out how to look for an address balance using Electrum RPC:</p>

<pre><code>{"id":"myquery","method":"getaddressbalance","params":["14vuRY354EaxDu4WrgjtvoDEwntDNwMVbx"]}
</code></pre>

CC BY-SA 4.0
2020-07-23T22:29:05.963Z
Hi, I have an electrum server (electrs by blockstream) running with this parameter `--cookie=mynode:mypassword` would it be possible to share the curl command, adding also this cookie auth to send the request? Would be awesome.
firepol
CC BY-SA 3.0
2017-08-31T01:13:48.083Z
2017-08-31T01:13:48.083Z
Jirico
<p>Jirico's answer is the right one. Gotta make sure you put the address you're querying in params.</p>

<p>If you need more depth than just a balance, you can also getaddresshistory</p>

<pre><code>{"id":"myquery","method":"getaddresshistory","params":["14vuRY354EaxDu4WrgjtvoDEwntDNwMVbx"]}
</code></pre>

<p>You can find a list of commands here: <a href="https://bitzuma.com/posts/an-introduction-to-the-electrum-python-console/" rel="nofollow noreferrer">An Introduction to the Electrum Python Console</a></p>

CC BY-SA 4.0
2018-10-18T19:54:24.860Z
I just tried it and I got: {"result": [], "id": "curltext", "error": null} since I tried it on an empty address. What version of Electrum are you using?
J A Gonzalez
CC BY-SA 4.0
2018-09-06T05:18:46.843Z
2018-09-06T05:18:46.843Z
J A Gonzalez
<p>Suppose, I've dynamically -- via the command line/RPC -- created an address or payment_query in Electrum. And saved its details in a database along with the amount of bitcoins I expect to receive. </p>

<p>How can then check/poll if that amount of bitcoins has arrived to that address? Also via the command line/RPC. </p>

<p>I don't want to be notified by Electrum, rather I want to poll Electrum daemon myself. Hence an http request-callback which Electrum can send to a URL isn't an option I'm looking for. Also, at the moment, I don't have a blockchain locally. Maybe later I'll add it, though.</p>

CC BY-SA 3.0
2017-08-31T01:04:50.700Z
I'd like to know this too. If you get something please update this thread.
Jirico
<api><json-rpc><electrum><balance>
Checking/polling a balance of an address in Electrum via the command line/RPC
Kolayn
# Checking/polling a balance of an address in Electrum via the command line/RPC

(Asked by: username_0 on 2017-02-21)

Suppose, I've dynamically -- via the command line/RPC -- created an address or payment\_query in Electrum. And saved its details in a database along with the amount of bitcoins I expect to receive.

How can then check/poll if that amount of bitcoins has arrived to that address? Also via the command line/RPC.

I don't want to be notified by Electrum, rather I want to poll Electrum daemon myself. Hence an http request-callback which Electrum can send to a URL isn't an option I'm looking for. Also, at the moment, I don't have a blockchain locally. Maybe later I'll add it, though.

**Tags:** api, json-rpc, electrum, balance

> **Comments:**
> **username_1**: I'd like to know this too. If you get something please update this thread.  

---

## 3 answers

### Answer by username_2 on 2017-09-01. Score: 2

There are several ways depending on what you are using. If you are wanting to query the daemon - one must assume you are running a Linux box or VPS

You do not want or need an " address balance " - you need YOUR wallet balance

This question has already been partially answered here => [How would one monitor an address for a transaction and 1 confirmation in PHP?](https://bitcoin.stackexchange.com/questions/44373/how-would-one-monitor-an-address-for-a-transaction-and-1-confirmation-in-php/44398#44398)

The best way however is to use what the Electrum docs recommend - a curl call like this => `curl --data-binary '{"id":"curltext","method":"getbalance","params":{"funded":true}}' http://127.0.0.1:7777`

If you are using PHP - it would look something like this:

```
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "http://127.0.0.1:7777");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"id\":\"curltext\",\"method\":\"getbalance\",\"params\":{\"funded\":true}}");
curl_setopt($ch, CURLOPT_POST, 1);

$headers = array();
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close ($ch);

```

You could make this inside a try-catch and trigger it by a cron job running at whatever interval you want to check

What comes back is a JSON-RPC file which you can decode into an array

```
$result =  json_decode($response, true);

```

and plug that into another variable for the single thing or things you want to work on from there

```
$wanted = $result["result"]["xxxxxxxxx"];

```

any of the parameters can be passed as a variable to the curl call

for instance to add a request it would go like this:

```
curl_setopt($ch, CURLOPT_POSTFIELDS, "{\"id\":\"curltext\",\"method\":\"addrequest\",\"params\":{\"amount\":\"$how_much\",\"memo\":\"$your_memo->some_data_field\"}}");

```

You just need to run a "getbalance " - or any - command see what it returns and adjust your code to pull the returned value from "result" - you just test for a greater than " 0 " and then empty the wallet by sending it to another wallet and wait for the next payment

You could then use that data to trigger a "do something" like the email example in the above link from the middle example there.


---

### Answer by username_1 on 2017-08-31. Score: 1

Just found out how to look for an address balance using Electrum RPC:

```
{"id":"myquery","method":"getaddressbalance","params":["14vuRY354EaxDu4WrgjtvoDEwntDNwMVbx"]}

```

> **Comments:**
> **username_3**: Hi, I have an electrum server (electrs by blockstream) running with this parameter `--cookie=mynode:mypassword` would it be possible to share the curl command, adding also this cookie auth to send the request? Would be awesome.  

---

### Answer by username_4 on 2018-09-06. Score: 1

username_1's answer is the right one. Gotta make sure you put the address you're querying in params.

If you need more depth than just a balance, you can also getaddresshistory

```
{"id":"myquery","method":"getaddresshistory","params":["14vuRY354EaxDu4WrgjtvoDEwntDNwMVbx"]}

```

You can find a list of commands here: [An Introduction to the Electrum Python Console](https://bitzuma.com/posts/an-introduction-to-the-electrum-python-console/)

> **Comments:**
> **username_4**: I just tried it and I got: {"result": [], "id": "curltext", "error": null} since I tried it on an empty address. What version of Electrum are you using?  

---

