BitcoinDatabase.com

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.

or try it below ↓

REST API · SQL · dashboards · indexed from genesis

Query Console
btc
try:

Hit Run to query the fully-indexed Bitcoin blockchain.

BTC

30-day trend

informational on-chain data · not financial advice

REST API · SQL · dashboards, one indexed dataset. Querying the indexed Bitcoin blockchain ...

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.

REST API SQL DASHBOARDS WEBHOOKS CSV EXPORT

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
GET /v1/address/{addr} query result
200 · JSON
{
  "address": "bc1qxy2k…l0wdv8",
  "balance_btc": 68432.10,
  "balance_usd": 4612165420,
  "tx_count": 1284,
  "unspent_outputs": 37,
  "first_seen": "2014-02-09"
}
indexed from genesis · to the satoshi ✓ reconciled block-by-block

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

Call a Bitcoin data API over HTTP with the requests library. Install requests, send a GET to the endpoint with your API key in an Authorization header, and call .json() on the response to get a Python dict. No Bitcoin-specific package is required, because the work of indexing the chain happens on the server side.
It depends which job you mean. For building and signing transactions, python-bitcoinlib and bitcoinlib are the two established choices, at versions 0.12.2 and 0.7.9 on PyPI as of 12 August 2026. For reading chain data, the best answer is usually no Bitcoin library at all: requests against an indexed API is less code and does not tie you to a package release cycle.
There are several, but they hold protocol logic rather than the blockchain itself. A library can parse a raw transaction, derive an address or sign a spend on your machine. It cannot tell you an address balance without asking a node or an API, because that answer requires an index over every block, which is hundreds of gigabytes of data.
Send one GET request to an address endpoint and read the balance field from the JSON. With BitcoinDatabase that is a call to /v1/address/{address} with a bearer token, returning the confirmed balance in satoshis as a Python integer. Divide by 100,000,000 with Decimal, not float, if you need to display BTC.
Yes. python-bitcoinrpc gives you an AuthServiceProxy that speaks JSON-RPC to a node you run, and python-bitcoinlib ships a proxy of its own. The catch is what Core stores: it keeps the UTXO set, not a per-address index, so address history and balance queries need txindex plus your own indexing layer on top.
Because several explorer endpoints return a bare string with a text/plain content type, and a bare hex string is not valid JSON. Tested on 12 August 2026, /api/blocks/tip/height returned 962164 and .json() parsed it fine as an integer, while /api/blocks/tip/hash on the same host raised JSONDecodeError. Use response.text for those endpoints and reserve .json() for endpoints that return an object.
Assume you cannot see the limit and write for failure. Of the public endpoints called on 12 August 2026, only BlockCypher returned an x-ratelimit-remaining header, so on the others the first signal is an HTTP 429. Mount a requests HTTPAdapter with a Retry that backs off on 429, 502, 503 and 504, and cache anything you poll more than once a second.
A library runs in your process and manipulates data you already hold: keys, addresses, raw transactions. An API is a service that answers questions about the chain, which requires someone to have indexed all of it. Most production Python code uses both, a library for anything cryptographic and an API for anything historical.

Explore more

More ways to query Bitcoin with BitcoinDatabase

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

See pricing

Indexed from genesis · REST · SQL · dashboards · addresses, transactions, UTXOs, metrics