Skip to main content

Easy Bitcoin RPC

Easy Bitcoin RPC is a simple and easy to use Python library for Bitcoin RPC

Installation

Use the package manager pip to install.

pip install easybitcoinrpc

Usage

Connecting

from easybitcoinrpc import RPC

# RPC() returns connection object

rpc = RPC() # defaults: ip=127.0.0.1, port=8332, user="user", password="password", wallet_name=None

rpc = RPC(user="rpcuser", password="rpcpassword")

rpc = RPC(ip="192.168.1.1", port=9999, user="rpcuser", password="rpcpassword")

rpc = RPC(wallet_name="Wallet")

Specifing wallet when connection is made is prefered method to get access to wallet, loading wallet after connecting sometimes dosn't work.

RPC methods

RPC object has methods for all Bitcoins RPC calls and those methods are seperated into sections as on Bitcoin RPC API Reference

from easybitcoinrpc import RPC
rpc = RPC()

rpc.blockchain # returns object which has all methods from blockchain category
rpc.wallet # returns object which has all methods from wallet category
rpc.util # returns object which has all methods from util category
rpc.mining # returns object which has all methods from mining category
rpc.network # returns object which has all methods from network category
rpc.generating # returns object which has all methods from generating category
rpc.control # returns object which has all methods from control category
rpc.transactions # returns object which has all methods from transactions category

rpc.client.call("getbestblockhash") # any RPC command can be called directly
rpc.client.call("getblock", block_hash, 2) # parameters follow the command

All methods have documentation copied from Bitcoin RPC API Reference, they also have parameters specified with their types and their default values.

Data

Methods for blocks and transactions return frozen dataclasses: Block, Transaction, Vin, Vout, ScriptSig, ScriptPubKey, TransactionSummary. Every field is a plain attribute and amounts are Decimal, never float.

from easybitcoinrpc import RPC

rpc = RPC()

block = rpc.blockchain.get_block(669376, 2)
print(block.height, block.mined_at, block.transaction_count)

for transaction in block.transactions:
    if transaction.is_segwit:
        print(transaction.txid, transaction.total_output)

get_block is overloaded on the verbosity: 0 returns the hex string, 1 and 2 return a Block, and only 2 fills block.transactions.

raw_hex = rpc.blockchain.get_block(669376, 0)
with_txids = rpc.blockchain.get_block(669376)
with_transactions = rpc.blockchain.get_block(669376, 2)

Batching

Anything that would otherwise be a loop of calls goes out as one JSON-RPC batch.

blocks = rpc.blockchain.get_blocks([669376, 669377, 669378])
transactions = rpc.transactions.get_transactions([first_txid, second_txid])

Transaction summary

TransactionSummary resolves the spent outputs into addresses and amounts. The funding transactions are fetched in a single batch.

summary = rpc.transactions.get_transaction_summary(txid)

for entry in summary.inputs:
    print(entry.address, entry.amount)

print(summary.total_input, summary.total_output, summary.fee)

The price is an argument, so the library never reaches out to a price feed on its own.

from decimal import Decimal

print(summary.value_in(Decimal("42000")))

Errors

A rejected call raises a subclass of RpcError carrying the node's code and message.

from easybitcoinrpc import RPC, WalletNotFoundError, AuthenticationError, RpcError

try:
    rpc.wallet.get_balance()
except WalletNotFoundError:
    ...
except AuthenticationError:
    ...
except RpcError as error:
    print(error.code, error.message)

Closing the connection

RPC keeps one pooled HTTP session and works as a context manager.

with RPC(user="rpcuser", password="rpcpassword") as rpc:
    print(rpc.blockchain.get_block_count())

Metadata

Release files for easybitcoinrpc 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easybitcoinrpc 2.0.0
File Size Uploaded Provenance Actions
easybitcoinrpc-2.0.0.tar.gz 46.0 kB With provenance Details for easybitcoinrpc-2.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for easybitcoinrpc 2.0.0
File Interpreter ABI Platform Actions
easybitcoinrpc-2.0.0-py3-none-any.whl Python 3 none any Details for easybitcoinrpc-2.0.0-py3-none-any.whl

Total release size: 90.2 kB

Release files / easybitcoinrpc-2.0.0.tar.gz

Download URL easybitcoinrpc-2.0.0.tar.gz
Size 46.0 kB
Tags Source
SHA-256 checksum
How to use checksums
f4ffb8dac7f620be0df30941b61b12469de33d7fa7daf91d6b37cedb03640312
BLAKE2b-256 checksum
How to use checksums
fa7eea3d33d03f5eb938ec3bdf854a9ef63e4bcab253641a5081ac258219c47c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Release files / easybitcoinrpc-2.0.0-py3-none-any.whl

Download URL easybitcoinrpc-2.0.0-py3-none-any.whl
Size 44.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d13850c55f419419403edc66fae8ffa94f6791789c6a64708781a46f02daf880
BLAKE2b-256 checksum
How to use checksums
daaf447c5661e3ac4123d4a853898d992c9fabbf8bb994634727d9d461be8472
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

Security for easybitcoinrpc 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for easybitcoinrpc-2.0.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 14, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page