| Crates.io | brk_query |
| lib.rs | brk_query |
| version | 0.1.0-beta.0 |
| created_at | 2025-03-02 10:11:07.341218+00 |
| updated_at | 2026-01-25 13:23:15.20692+00 |
| description | An interface to find and format data from BRK |
| homepage | https://bitcoinresearchkit.org |
| repository | https://github.com/bitcoinresearchkit/brk |
| max_upload_size | |
| id | 1574470 |
| size | 132,105 |
Query interface for Bitcoin indexed and computed data.
Query blocks, transactions, addresses, and 1000+ on-chain metrics through a unified API. Supports pagination, range queries, and multiple output formats.
from=-100)AsyncQuery wrapperlet query = Query::build(&reader, &indexer, &computer, Some(mempool));
// Current height
let height = query.height();
// Metric queries (two-phase: resolve then format)
let resolved = query.resolve(MetricSelection {
metrics: vec!["supply".into()],
index: Index::Height,
range: DataRangeFormat::default(),
}, usize::MAX)?;
let data = query.format(resolved)?;
// Block queries
let info = query.block_by_height(Height::new(840_000))?;
// Transaction queries
let tx = query.transaction(txid.into())?;
// Address queries
let stats = query.address(address)?;
| Domain | Methods |
|---|---|
| Metrics | metrics, resolve, format, metric_to_indexes |
| Blocks | block, block_by_height, blocks, block_txs, block_status, block_by_timestamp |
| Transactions | transaction, transaction_status, transaction_hex, outspend, outspends |
| Addresses | address, address_txids, address_utxos |
| Mining | difficulty_adjustments, hashrate, mining_pools, reward_stats |
| Mempool | mempool_info, recommended_fees, mempool_blocks |
let async_query = AsyncQuery::build(&reader, &indexer, &computer, mempool);
// Run blocking queries in thread pool
let result = async_query.run(|q| q.block_by_height(height)).await;
// Access inner Query
let height = async_query.inner().height();
Use mimalloc v3 as the global allocator to reduce memory usage.
brk_indexer for raw indexed databrk_computer for derived metricsbrk_mempool for mempool queriesbrk_reader for raw block access