Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/interlay/esplora-btc-api
Blockstream Esplora Client (Typescript)
https://github.com/interlay/esplora-btc-api
bitcoin blockstream typescript
Last synced: 19 days ago
JSON representation
Blockstream Esplora Client (Typescript)
- Host: GitHub
- URL: https://github.com/interlay/esplora-btc-api
- Owner: interlay
- License: apache-2.0
- Created: 2020-07-06T14:10:18.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-07-12T15:08:34.000Z (over 2 years ago)
- Last Synced: 2024-10-18T17:03:35.038Z (29 days ago)
- Topics: bitcoin, blockstream, typescript
- Language: Makefile
- Homepage:
- Size: 85.9 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# [Blockstream Esplora](https://github.com/Blockstream/esplora) OpenAPI Spec & Clients
Built using [OpenAPI](https://github.com/OpenAPITools/openapi-generator). Requires [openapi-generator-cli](https://github.com/OpenAPITools/openapi-generator-cli).
```shell
make rust-client
make ts-client
```## Typescript (Axios)
### Install
```bash
yarn install @interlay/esplora-btc-api
```### Build
```bash
cd ts-client
yarn install
yarn build
```### Examples
#### Get the current chain's best height
```typescript
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
```typescript
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();
```