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?
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.