@stacks/blockchain-api-client
A JS Client for the Stacks Blockchain API
Features
This package provides the ability to:
- Execute REST API requests against the Stacks Blockchain API
- Subscribe to WebSockets for real-time Stacks updates (for addresses or transactions)
- Full type safety for WebSocket and API requests and responses
Installation
You can install this package using NPM:
npm install --save-dev @stacks/blockchain-api-client
Usage
Here is an example code that connects with the WebSocket server and subscribes to updates for a specific Stacks address:
import { connectWebSocketClient } from '@stacks/blockchain-api-client';
const client = await connectWebSocketClient('ws://stacks-node-api.blockstack.org/');
const sub = await client.subscribeAddressTransactions('ST3GQB6WGCWKDNFNPSQRV8DY93JN06XPZ2ZE9EVMA', event =>
console.log(event);
);
await sub.unsubscribe();
Documentation
You can find full references here.
Known Issues
- The TypeScript definitions for several objects involving type unions, including transactions, are incorrectly specified as only
object
.