Skip to content
This repository was archived by the owner on Dec 19, 2025. It is now read-only.

Repository files navigation

blockbook-client

Typescript library for interacting with Trezor's blockbook API.

Usage

npm i blockbook-client

In typescript

import{Blockbook}from'blockbook-client'constblockbook=newBlockbook({nodes: ['btc1.trezor.io','btc2.trezor.io'],})// Example methods using httpawaitblockbook.getStatus()awaitblockbook.getBlockHash(100000)// -> '000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506'awaitblockbook.getTx('b62aa5203fa27495ea431b91a5090aab741c8c39cc03ec4c1f4f4e157507595f')awaitblockbook.getTxSpecific('b62aa5203fa27495ea431b91a5090aab741c8c39cc03ec4c1f4f4e157507595f')awaitblockbook.getAddressDetails('193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7')awaitblockbook.getXpubDetails('xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8',{details: 'txids'})awaitblockbook.getUtxosForAddress('193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7')awaitblockbook.getUtxosForXpub('xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8',{confirmed: true})awaitblockbook.getBlock(100000)awaitblockbook.sendTx('<hex tx data>')// To use websocketsawaitblockbook.connect()awaitblockbook.subscribeNewBlock(({ height, hash })=>console.log('new block',height,hash))awaitblockbook.subscribeAddresses(['193P6LtvS4nCnkDvM9uXn1gsSRqh4aDAz7'],({ address, tx })=>console.log('new tx for address',address,tx))awaitblockbook.unsubscribeNewBlock()awaitblockbook.unsubscribeAddresses()awaitblockbook.disconnect()// For more specific typings of bitcoin-like or ethereum-like coins use one of// the following classes instead. The `Blockbook` class will work with any coin// but returns more optional fields than the following.import{BlockbookBitcoin,BlockbookEthereum}from'blockbook-client'

In javascript

const{ Blockbook }=require('blockbook-client')constblockbook=newBlockbook({nodes: ['btc1.trezor.io','btc2.trezor.io'],disableTypeValidation: true,// Turns off runtime type validation})

Docs

open docs/index.html

About

Typescript client for interacting with Trezor's blockbook API

Resources

Stars

5 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages