#bitcoin-blockchain #cryptocurrency #quant #finance #blockchain-explorer #parser #science #bitcoin

yanked bitcoinquery

A Package for Reading from Bitcoin Core Binary Blockchain

0.1.30 Sep 22, 2021
0.1.27 Sep 22, 2021

#23 in #quant

Download history 1/week @ 2023-10-21 29/week @ 2023-10-28 2/week @ 2023-11-04 16/week @ 2023-11-18 64/week @ 2023-11-25 16/week @ 2023-12-09 32/week @ 2023-12-23 1/week @ 2023-12-30 3/week @ 2024-01-13 18/week @ 2024-01-20 64/week @ 2024-01-27

85 downloads per month

Custom license



bitcoinquery is a python package developed in rust for accessing bitcoin-core binary files as a database.

How to install?

This library is designed for both python and rust.

For python users, pip install bitcoinquery.

For rust users, include bitcoinquey="0.1" in Cargo.toml.

Install Requirements

Currently, only macOS py39 wheels are provided.

For pip to build the package on other OS or python version, make sure that rust toolchain is installed, and cmake is also installed.


For API documentation, go to Documentation.

Compatibility Note

This package deals with the binary file of another software Bitcoin Core. It might not be compatible with older Bitcoin Core versions.

Currently, it is compatible with Bitcoin Core version Bitcoin Core version v0.21.1.0-g194b9b8792d9b0798fdb570b79fa51f1d1f5ebaf Copyright (C) 2009-2020 The Bitcoin Core developers.


It contains one class BitcoinDB.

import bitcoinquery as bq

# parse the same path as `--datadir` argument for `bitcoind`.
db = bq.BitcoinDB("~/Bitcoin")

# get the length of the longest chain currently on disk.

# get block of a certain height

# to retrieve the connected outputs of each inputs as well
db.get_block(1000, connected=True)

# get block hash of a certain height.

# a fast method for getting just the header.
# in memory query, no disk access

# get block of height 1000.
db.get_height_from_hash("some hash")

# get blocks of heights 100..199.
# (This method uses `rayon` parallel computing to take advantage of multicore)
# this function returns json string instead of object.
db.get_block_batch(list(range(100, 200)))

# get transaction from txid.
# This queries the `levelDB` each time, thus it is relatively slow.
db.get_transaction("some txid")

# get the height of the block which this transaction belongs.
db.get_height_from_txid("some txid")

# get the script type and addresses from a script public key
db.parse_script("some hex script pubic key")

# use iterator
for block in db.get_block_iter_range(start=1000, end=2000):

# use iterator, iterate over heights
for block in db.get_block_iter_array(heights=[1, 3, 5, 7, 9]):
# use iterator, connect outpoints
for block in db.get_block_iter_range(end=700000, connected=True):


~211K SLoC