Query the chain · Bitcoin data in Python
Bitcoin API Python: Bitcoin Python Library for On-Chain Data
Bitcoin API Python work is one HTTP call away: import requests, hit an endpoint, read a balance. The harder decision is which source you point it at, because most Bitcoin Python libraries sign transactions rather than answer questions about the chain.
REST API · SQL · dashboards · indexed from genesis
Hit Run to query the fully-indexed Bitcoin blockchain.
BTC
30-day trend
informational on-chain data · not financial advice
That distinction catches out almost everyone who starts here. Search for a Bitcoin Python library and you land on packages built for key handling, address derivation and transaction construction. They are excellent at that job. None of them holds the chain, so the moment you ask a question like "what did this address hold in March 2021" or "which UTXOs are sitting behind this xpub", the library has to go and ask a third party anyway. The data has to come from an index somewhere, and the only real choice is whose index.
BitcoinDatabase is that index, reachable from Python over plain HTTP. Every block since the 2009 genesis block is parsed and reconciled, and the REST API at api.bitcoindatabase.com/v1 answers with JSON that requests turns into a dict in one line. Address balances to the satoshi, full transaction detail with inputs and outputs, UTXO sets, xpub derivation, block data and computed metrics all come from the same integration, and analysts on the same team can hit the same data with SQL instead. No node to sync, no indexer to build, no second provider for history.
The comparison table below lays out every realistic way to get chain data into Python, what each one actually installs, and where each one runs out. Package versions were checked against PyPI on 12 August 2026 and every public endpoint mentioned was called from Python the same day. This is informational on-chain data only, not financial or investment advice.
Indexed from genesis queryable in seconds
On-chain data not financial advice
Why it works
What you get with Bitcoin data in Python
requests is the whole client
You do not need a Bitcoin package or a generated client to read the chain. The REST API returns JSON, so a GET with a bearer token and one call to .json() gives you a Python dict. That keeps the integration surface small enough to read in a code review, and it works the same from a Django view, a Celery task or a notebook.
Satoshis stay exact in Python
Amounts come back as integer satoshis, and Python integers have arbitrary precision, so totals across tens of thousands of outputs never drift. Convert to BTC at the display layer with Decimal rather than float. This is one place Python is genuinely easier to get right than JavaScript, where large satoshi sums start bumping into the safe integer ceiling.
One integration covers history
Point-in-time balances, full address history and UTXO sets come from the same base URL as a current balance lookup. Teams that start on a public explorer usually end up bolting on a second provider the first time they need a figure as of a past date, because explorer endpoints return current aggregates only.
Side by side
Ways to get Bitcoin data into Python
Every realistic option a Python developer picks between, with what it installs and where it stops. Package versions read from PyPI and every public endpoint called from Python on 12 August 2026.
| Approach | pip install | What it actually gives you | Where it stops |
|---|---|---|---|
| BitcoinDatabase REST | requests | Balances, transactions, UTXOs, xpubs, blocks and metrics, indexed since 2009, plus SQL over the same data | Paid from 49 dollars a month, no free plan |
| mempool.space / Esplora | requests | Address aggregates, transactions, blocks and fee estimates with no API key at all | No published rate limit, no uptime commitment, some endpoints return plain text |
| BlockCypher SDK | blockcypher (1.0.93) | Explorer data and node access through a maintained Python client | Free tier is 3 requests a second and 100 an hour, paid from 119 dollars a month |
| Bitcoin Core RPC | python-bitcoinrpc (1.0) | AuthServiceProxy against your own node, the complete RPC surface | You sync and run the node, and Core keeps no address index by default |
| python-bitcoinlib | python-bitcoinlib (0.12.2) | Protocol primitives: serialization, scripts, addresses, an RPC proxy | Builds and parses transactions. It is not a data source |
| bitcoinlib | bitcoinlib (0.7.9) | Keys, HD wallets and transaction construction in one package | Wallet library. Chain lookups are delegated to third-party providers |
| BigQuery dataset | google-cloud-bigquery (3.43.0) | SQL across the whole chain from a warehouse copy | 6.25 dollars per TiB scanned, and the copy sits a few blocks behind the tip |
| Bitquery GraphQL | requests | Multi-chain GraphQL behind a single endpoint | 79 dollars a month for commercial use, and points are deducted even when your client times out |
The split down the middle of this table is the thing to notice. The first four rows and the last two are data sources: you ask a question and something that holds an index answers it. python-bitcoinlib and bitcoinlib are the two rows that are not, and they are also the two that dominate a search for a Bitcoin Python library. Both are well-built packages doing a different job, so pairing one of them with a data API is a perfectly normal setup rather than a mistake.
What it handles
The indexed Bitcoin chain, queryable your way
Look up an address, a transaction, a UTXO, the rich list or an on-chain metric, by REST API, SQL or dashboard. The same authoritative data, reconciled block-by-block against the canonical chain, without running a node.
- Read any address balance into Python as an integer satoshi value
- Page through complete address transaction history
- Pull UTXO sets and xpub-derived addresses without a node
- Run SQL over the indexed chain and load results into pandas
- Handle rate limits with retry and backoff you control
- Keep one integration instead of a provider per question
{
"address": "bc1qxy2k…l0wdv8",
"balance_btc": 68432.10,
"balance_usd": 4612165420,
"tx_count": 1284,
"unspent_outputs": 37,
"first_seen": "2014-02-09"
}
Why BitcoinDatabase
One platform, queryable three ways
Not a raw node to sync, not an indexer to build, and not five vendors to stitch together. The fully-indexed Bitcoin blockchain, available as a REST API, as SQL, and as dashboards, on one authoritative dataset.
REST API
Typed JSON for addresses, transactions, balances, UTXOs and metrics. Drop it into apps, wallets, explorers and agents with curl, Python or any HTTP client.
SQL access
Run SQL directly against the indexed Bitcoin dataset for ad-hoc analysis, cohorts and exports, the same data the API and dashboards read from.
Compliance-first
Informational on-chain data and analytics only. Entity labels and flow tracing are framed as tooling to support a regulated team's own review, not accusations.
Good questions
Questions about Bitcoin data in Python
Explore more
More ways to query Bitcoin with BitcoinDatabase
Bitcoin API
Query addresses, transactions and balances across the whole indexed chain in one call.
Learn moreQuery the Bitcoin blockchain with SQL
Write plain SQL against the whole indexed chain, no node, no ETL.
Learn moreBitcoin node API
JSON-RPC style access to blocks, transactions and balances, with no Bitcoin Core to run.
Learn moreBitcoin RPC API
Make JSON-RPC style calls like getblock and getrawtransaction over clean REST, no node to sync.
Learn moreBitcoin block explorer API
Power an explorer with blocks, transactions and addresses, no node to maintain.
Learn moreBitcoin address lookup
Look up any Bitcoin address: balance, full history and UTXOs in one query.
Learn moreStop running a node. Just query Bitcoin.
Run your first query now and get on-chain data back by REST API, SQL or dashboard, indexed from the genesis block. Informational on-chain data only, not financial advice.
Indexed from genesis · REST · SQL · dashboards · addresses, transactions, UTXOs, metrics