I want to use my electrum wallet balance in my another python application. How do I make a call to the getbalance() function?

  • It should be something like electrum daemon start; electrum getbalance, but I can't get it to work on my machine.
    – Nick ODell
    Apr 19, 2015 at 9:10

2 Answers 2


You might find it easier to just query an electrum server directly. Stratum is a nice protocol in that it's easy to use in an ad-hoc fashion.

If you're using python3 this is almost certainly the easier solution, too.

def get_from_electrum(method, params=[]):
    params = [params] if type(params) is not list else params
    s = socket.create_connection(('ecdsa.net', 50001))
    s.send(json.dumps({"id": 0, "method": method, "params": params}).encode() + b'\n')
    return json.loads(s.recv(99999)[:-1].decode())

get_from_electrum('blockchain.address.get_balance', '1MaxKayeQg4YhFkzFz4x6NDeeNv1bwKKVA')


    "result": {
        "unconfirmed": 0,
        "confirmed": 237093847
    "id": 0

Documentation: https://electrum.orain.org/wiki/Stratum_protocol_specification

  • This no longer works because the target machine actively refused the connection (maybe now it uses another host or port), and also that link is broken. Oct 5, 2015 at 14:44

You can use electrum as a library in your scripts.

There is a scripts directory in the github repo, with examples to learn from.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.