Files
brk/modules/brk-client/docs/classes/BrkClient.md
2026-01-11 17:19:00 +01:00

28 KiB

brk-client


brk-client / BrkClient

Class: BrkClient

Defined in: Developer/brk/modules/brk-client/index.js:5136

Main BRK client with catalog tree and API methods

Extends

  • BrkClientBase

Constructors

Constructor

new BrkClient(options): BrkClient

Defined in: Developer/brk/modules/brk-client/index.js:6033

Parameters

options

string | BrkClientOptions

Returns

BrkClient

Overrides

BrkClientBase.constructor

Properties

tree

tree: CatalogTree

Defined in: Developer/brk/modules/brk-client/index.js:6036

Methods

get()

get<T>(path, onUpdate?): Promise<T>

Defined in: Developer/brk/modules/brk-client/index.js:619

Make a GET request with stale-while-revalidate caching

Type Parameters

T

T

Parameters

path

string

onUpdate?

(value) => void

Called when data is available

Returns

Promise<T>

Inherited from

BrkClientBase.get


getAddress()

getAddress(address): Promise<AddressStats>

Defined in: Developer/brk/modules/brk-client/index.js:7444

Address information

Retrieve comprehensive information about a Bitcoin address including balance, transaction history, UTXOs, and estimated investment metrics. Supports all standard Bitcoin address types (P2PKH, P2SH, P2WPKH, P2WSH, P2TR, etc.).

Parameters

address

string

Returns

Promise<AddressStats>


getAddressTxs()

getAddressTxs(address, after_txid?, limit?): Promise<string[]>

Defined in: Developer/brk/modules/brk-client/index.js:7458

Address transaction IDs

Get transaction IDs for an address, newest first. Use after_txid for pagination.

Parameters

address

string

after_txid?

string

Txid to paginate from (return transactions before this one)

limit?

number

Maximum number of results to return. Defaults to 25 if not specified.

Returns

Promise<string[]>


getAddressTxsChain()

getAddressTxsChain(address, after_txid?, limit?): Promise<string[]>

Defined in: Developer/brk/modules/brk-client/index.js:7476

Address confirmed transactions

Get confirmed transaction IDs for an address, 25 per page. Use ?after_txid= for pagination.

Parameters

address

string

after_txid?

string

Txid to paginate from (return transactions before this one)

limit?

number

Maximum number of results to return. Defaults to 25 if not specified.

Returns

Promise<string[]>


getAddressTxsMempool()

getAddressTxsMempool(address): Promise<string[]>

Defined in: Developer/brk/modules/brk-client/index.js:7494

Address mempool transactions

Get unconfirmed transaction IDs for an address from the mempool (up to 50).

Parameters

address

string

Returns

Promise<string[]>


getAddressUtxo()

getAddressUtxo(address): Promise<Utxo[]>

Defined in: Developer/brk/modules/brk-client/index.js:7506

Address UTXOs

Get unspent transaction outputs for an address.

Parameters

address

string

Returns

Promise<Utxo[]>


getBlockByHash()

getBlockByHash(hash): Promise<BlockInfo>

Defined in: Developer/brk/modules/brk-client/index.js:7530

Block information

Retrieve block information by block hash. Returns block metadata including height, timestamp, difficulty, size, weight, and transaction count.

Parameters

hash

string

Returns

Promise<BlockInfo>


getBlockByHashRaw()

getBlockByHashRaw(hash): Promise<number[]>

Defined in: Developer/brk/modules/brk-client/index.js:7542

Raw block

Returns the raw block data in binary format.

Parameters

hash

string

Returns

Promise<number[]>


getBlockByHashStatus()

getBlockByHashStatus(hash): Promise<BlockStatus>

Defined in: Developer/brk/modules/brk-client/index.js:7554

Block status

Retrieve the status of a block. Returns whether the block is in the best chain and, if so, its height and the hash of the next block.

Parameters

hash

string

Returns

Promise<BlockStatus>


getBlockByHashTxidByIndex()

getBlockByHashTxidByIndex(hash, index): Promise<string>

Defined in: Developer/brk/modules/brk-client/index.js:7567

Transaction ID at index

Retrieve a single transaction ID at a specific index within a block. Returns plain text txid.

Parameters

hash

string

Bitcoin block hash

index

number

Transaction index within the block (0-based)

Returns

Promise<string>


getBlockByHashTxids()

getBlockByHashTxids(hash): Promise<string[]>

Defined in: Developer/brk/modules/brk-client/index.js:7579

Block transaction IDs

Retrieve all transaction IDs in a block by block hash.

Parameters

hash

string

Returns

Promise<string[]>


getBlockByHashTxsByStartIndex()

getBlockByHashTxsByStartIndex(hash, start_index): Promise<Transaction[]>

Defined in: Developer/brk/modules/brk-client/index.js:7592

Block transactions (paginated)

Retrieve transactions in a block by block hash, starting from the specified index. Returns up to 25 transactions at a time.

Parameters

hash

string

Bitcoin block hash

start_index

number

Starting transaction index within the block (0-based)

Returns

Promise<Transaction[]>


getBlockHeight()

getBlockHeight(height): Promise<BlockInfo>

Defined in: Developer/brk/modules/brk-client/index.js:7518

Block by height

Retrieve block information by block height. Returns block metadata including hash, timestamp, difficulty, size, weight, and transaction count.

Parameters

height

number

Returns

Promise<BlockInfo>


getBlocks()

getBlocks(): Promise<BlockInfo[]>

Defined in: Developer/brk/modules/brk-client/index.js:7602

Recent blocks

Retrieve the last 10 blocks. Returns block metadata for each block.

Returns

Promise<BlockInfo[]>


getBlocksByHeight()

getBlocksByHeight(height): Promise<BlockInfo[]>

Defined in: Developer/brk/modules/brk-client/index.js:7614

Blocks from height

Retrieve up to 10 blocks going backwards from the given height. For example, height=100 returns blocks 100, 99, 98, ..., 91. Height=0 returns only block 0.

Parameters

height

number

Returns

Promise<BlockInfo[]>


getHealth()

getHealth(): Promise<Health>

Defined in: Developer/brk/modules/brk-client/index.js:8008

Health check

Returns the health status of the API server

Returns

Promise<Health>


getMempoolInfo()

getMempoolInfo(): Promise<MempoolInfo>

Defined in: Developer/brk/modules/brk-client/index.js:7624

Mempool statistics

Get current mempool statistics including transaction count, total vsize, and total fees.

Returns

Promise<MempoolInfo>


getMempoolTxids()

getMempoolTxids(): Promise<string[]>

Defined in: Developer/brk/modules/brk-client/index.js:7634

Mempool transaction IDs

Get all transaction IDs currently in the mempool.

Returns

Promise<string[]>


getMetric()

getMetric(metric): Promise<Index[]>

Defined in: Developer/brk/modules/brk-client/index.js:7646

Get supported indexes for a metric

Returns the list of indexes are supported by the specified metric. For example, realized_price might be available on dateindex, weekindex, and monthindex.

Parameters

metric

string

Returns

Promise<Index[]>


getMetricByIndex()

getMetricByIndex(index, metric, count?, format?, from?, to?): Promise<AnyMetricData>

Defined in: Developer/brk/modules/brk-client/index.js:7663

Get metric data

Fetch data for a specific metric at the given index. Use query parameters to filter by date range and format (json/csv).

Parameters

index

Index

Aggregation index

metric

string

Metric name

count?

any

Number of values to return (ignored if to is set)

format?

Format

Format of the output

from?

any

Inclusive starting index, if negative counts from end

to?

any

Exclusive ending index, if negative counts from end

Returns

Promise<AnyMetricData>


getMetricsBulk()

getMetricsBulk(count?, format?, from?, index?, metrics?, to?): Promise<AnyMetricData[]>

Defined in: Developer/brk/modules/brk-client/index.js:7688

Bulk metric data

Fetch multiple metrics in a single request. Supports filtering by index and date range. Returns an array of MetricData objects.

Parameters

count?

any

Number of values to return (ignored if to is set)

format?

Format

Format of the output

from?

any

Inclusive starting index, if negative counts from end

index?

Index

Index to query

metrics?

string

Requested metrics

to?

any

Exclusive ending index, if negative counts from end

Returns

Promise<AnyMetricData[]>


getMetricsCatalog()

getMetricsCatalog(): Promise<TreeNode>

Defined in: Developer/brk/modules/brk-client/index.js:7706

Metrics catalog

Returns the complete hierarchical catalog of available metrics organized as a tree structure. Metrics are grouped by categories and subcategories. Best viewed in an interactive JSON viewer (e.g., Firefox's built-in JSON viewer) for easy navigation of the nested structure.

Returns

Promise<TreeNode>


getMetricsCount()

getMetricsCount(): Promise<MetricCount[]>

Defined in: Developer/brk/modules/brk-client/index.js:7716

Metric count

Current metric count

Returns

Promise<MetricCount[]>


getMetricsIndexes()

getMetricsIndexes(): Promise<IndexInfo[]>

Defined in: Developer/brk/modules/brk-client/index.js:7726

List available indexes

Returns all available indexes with their accepted query aliases. Use any alias when querying metrics.

Returns

Promise<IndexInfo[]>


getMetricsList()

getMetricsList(page?): Promise<PaginatedMetrics>

Defined in: Developer/brk/modules/brk-client/index.js:7738

Metrics list

Paginated list of available metrics

Parameters

page?

any

Pagination index

Returns

Promise<PaginatedMetrics>


getMetricsSearchByMetric()

getMetricsSearchByMetric(metric, limit?): Promise<string[]>

Defined in: Developer/brk/modules/brk-client/index.js:7754

Search metrics

Fuzzy search for metrics by name. Supports partial matches and typos.

Parameters

metric

string

limit?

number

Returns

Promise<string[]>


getTxByTxid()

getTxByTxid(txid): Promise<Transaction>

Defined in: Developer/brk/modules/brk-client/index.js:7769

Transaction information

Retrieve complete transaction data by transaction ID (txid). Returns the full transaction details including inputs, outputs, and metadata. The transaction data is read directly from the blockchain data files.

Parameters

txid

string

Returns

Promise<Transaction>


getTxByTxidHex()

getTxByTxidHex(txid): Promise<string>

Defined in: Developer/brk/modules/brk-client/index.js:7781

Transaction hex

Retrieve the raw transaction as a hex-encoded string. Returns the serialized transaction in hexadecimal format.

Parameters

txid

string

Returns

Promise<string>


getTxByTxidOutspendByVout()

getTxByTxidOutspendByVout(txid, vout): Promise<TxOutspend>

Defined in: Developer/brk/modules/brk-client/index.js:7794

Output spend status

Get the spending status of a transaction output. Returns whether the output has been spent and, if so, the spending transaction details.

Parameters

txid

string

Transaction ID

vout

number

Output index

Returns

Promise<TxOutspend>


getTxByTxidOutspends()

getTxByTxidOutspends(txid): Promise<TxOutspend[]>

Defined in: Developer/brk/modules/brk-client/index.js:7806

All output spend statuses

Get the spending status of all outputs in a transaction. Returns an array with the spend status for each output.

Parameters

txid

string

Returns

Promise<TxOutspend[]>


getTxByTxidStatus()

getTxByTxidStatus(txid): Promise<TxStatus>

Defined in: Developer/brk/modules/brk-client/index.js:7818

Transaction status

Retrieve the confirmation status of a transaction. Returns whether the transaction is confirmed and, if so, the block height, hash, and timestamp.

Parameters

txid

string

Returns

Promise<TxStatus>


getV1DifficultyAdjustment()

getV1DifficultyAdjustment(): Promise<DifficultyAdjustment>

Defined in: Developer/brk/modules/brk-client/index.js:7828

Difficulty adjustment

Get current difficulty adjustment information including progress through the current epoch, estimated retarget date, and difficulty change prediction.

Returns

Promise<DifficultyAdjustment>


getV1FeesMempoolBlocks()

getV1FeesMempoolBlocks(): Promise<MempoolBlock[]>

Defined in: Developer/brk/modules/brk-client/index.js:7838

Projected mempool blocks

Get projected blocks from the mempool for fee estimation. Each block contains statistics about transactions that would be included if a block were mined now.

Returns

Promise<MempoolBlock[]>


getV1FeesRecommended()

getV1FeesRecommended(): Promise<RecommendedFees>

Defined in: Developer/brk/modules/brk-client/index.js:7848

Recommended fees

Get recommended fee rates for different confirmation targets based on current mempool state.

Returns

Promise<RecommendedFees>


getV1MiningBlocksFeesByTimePeriod()

getV1MiningBlocksFeesByTimePeriod(time_period): Promise<BlockFeesEntry[]>

Defined in: Developer/brk/modules/brk-client/index.js:7860

Block fees

Get average block fees for a time period. Valid periods: 24h, 3d, 1w, 1m, 3m, 6m, 1y, 2y, 3y

Parameters

time_period

TimePeriod

Returns

Promise<BlockFeesEntry[]>


getV1MiningBlocksRewardsByTimePeriod()

getV1MiningBlocksRewardsByTimePeriod(time_period): Promise<BlockRewardsEntry[]>

Defined in: Developer/brk/modules/brk-client/index.js:7872

Block rewards

Get average block rewards (coinbase = subsidy + fees) for a time period. Valid periods: 24h, 3d, 1w, 1m, 3m, 6m, 1y, 2y, 3y

Parameters

time_period

TimePeriod

Returns

Promise<BlockRewardsEntry[]>


getV1MiningBlocksSizesWeightsByTimePeriod()

getV1MiningBlocksSizesWeightsByTimePeriod(time_period): Promise<BlockSizesWeights>

Defined in: Developer/brk/modules/brk-client/index.js:7884

Block sizes and weights

Get average block sizes and weights for a time period. Valid periods: 24h, 3d, 1w, 1m, 3m, 6m, 1y, 2y, 3y

Parameters

time_period

TimePeriod

Returns

Promise<BlockSizesWeights>


getV1MiningBlocksTimestamp()

getV1MiningBlocksTimestamp(timestamp): Promise<BlockTimestamp>

Defined in: Developer/brk/modules/brk-client/index.js:7896

Block by timestamp

Find the block closest to a given UNIX timestamp.

Parameters

timestamp

number

Returns

Promise<BlockTimestamp>


getV1MiningDifficultyAdjustments()

getV1MiningDifficultyAdjustments(): Promise<DifficultyAdjustmentEntry[]>

Defined in: Developer/brk/modules/brk-client/index.js:7906

Difficulty adjustments (all time)

Get historical difficulty adjustments. Returns array of [timestamp, height, difficulty, change_percent].

Returns

Promise<DifficultyAdjustmentEntry[]>


getV1MiningDifficultyAdjustmentsByTimePeriod()

getV1MiningDifficultyAdjustmentsByTimePeriod(time_period): Promise<DifficultyAdjustmentEntry[]>

Defined in: Developer/brk/modules/brk-client/index.js:7918

Difficulty adjustments

Get historical difficulty adjustments for a time period. Valid periods: 24h, 3d, 1w, 1m, 3m, 6m, 1y, 2y, 3y. Returns array of [timestamp, height, difficulty, change_percent].

Parameters

time_period

TimePeriod

Returns

Promise<DifficultyAdjustmentEntry[]>


getV1MiningHashrate()

getV1MiningHashrate(): Promise<HashrateSummary>

Defined in: Developer/brk/modules/brk-client/index.js:7928

Network hashrate (all time)

Get network hashrate and difficulty data for all time.

Returns

Promise<HashrateSummary>


getV1MiningHashrateByTimePeriod()

getV1MiningHashrateByTimePeriod(time_period): Promise<HashrateSummary>

Defined in: Developer/brk/modules/brk-client/index.js:7940

Network hashrate

Get network hashrate and difficulty data for a time period. Valid periods: 24h, 3d, 1w, 1m, 3m, 6m, 1y, 2y, 3y

Parameters

time_period

TimePeriod

Returns

Promise<HashrateSummary>


getV1MiningPoolBySlug()

getV1MiningPoolBySlug(slug): Promise<PoolDetail>

Defined in: Developer/brk/modules/brk-client/index.js:7952

Mining pool details

Get detailed information about a specific mining pool including block counts and shares for different time periods.

Parameters

slug

PoolSlug

Returns

Promise<PoolDetail>


getV1MiningPools()

getV1MiningPools(): Promise<PoolInfo[]>

Defined in: Developer/brk/modules/brk-client/index.js:7962

List all mining pools

Get list of all known mining pools with their identifiers.

Returns

Promise<PoolInfo[]>


getV1MiningPoolsByTimePeriod()

getV1MiningPoolsByTimePeriod(time_period): Promise<PoolsSummary>

Defined in: Developer/brk/modules/brk-client/index.js:7974

Mining pool statistics

Get mining pool statistics for a time period. Valid periods: 24h, 3d, 1w, 1m, 3m, 6m, 1y, 2y, 3y

Parameters

time_period

TimePeriod

Returns

Promise<PoolsSummary>


getV1MiningRewardStatsByBlockCount()

getV1MiningRewardStatsByBlockCount(block_count): Promise<RewardStats>

Defined in: Developer/brk/modules/brk-client/index.js:7986

Mining reward statistics

Get mining reward statistics for the last N blocks including total rewards, fees, and transaction count.

Parameters

block_count

number

Number of recent blocks to include

Returns

Promise<RewardStats>


getV1ValidateAddress()

getV1ValidateAddress(address): Promise<AddressValidation>

Defined in: Developer/brk/modules/brk-client/index.js:7998

Validate address

Validate a Bitcoin address and get information about its type and scriptPubKey.

Parameters

address

string

Bitcoin address to validate (can be any string)

Returns

Promise<AddressValidation>


getVersion()

getVersion(): Promise<string>

Defined in: Developer/brk/modules/brk-client/index.js:8018

API version

Returns the current version of the API server

Returns

Promise<string>