esplora-api-client
v0.4.1
Published
Built using [OpenAPI](https://github.com/OpenAPITools/openapi-generator).
Downloads
28
Maintainers
Readme
Blockstream Esplora Client
Built using OpenAPI.
Install
yarn install @interlay/esplora-btc-api
Build
Requires openapi-generator-cli.
yarn generate
yarn build
Examples
Get the current chain's best height
import * as esplora from '@interlay/esplora-btc-api';
async function main() {
let result = await new esplora.BlockApi().getLastBlockHeight();
console.log(result.data);
}
main();
Get a raw block and extract the header
import * as esplora from '@interlay/esplora-btc-api';
async function main() {
const api = new esplora.BlockApi();
const result = await api.getBlockRaw("$HASH", {responseType: 'arraybuffer'});
console.log(result.data.slice(0, 80).toString('hex'));
}
main();