@stacks/blockchain-api-client
Interact with the Stacks blockchain using a JavaScript client library.
The @stacks/blockchain-api-client
library provides a robust interface for interacting with the Stacks Blockchain API by offering type-safe methods to access REST and WebSocket endpoints.
The client includes automatically generated HTTP API methods, comprehensive Schemas for Clarity smart contract values, and a WebSocket client for real-time data streaming.
import { AccountsApi } from '@stacks/blockchain-api-client';const accounts = new AccountsApi(apiConfig);await accounts.getAccountTransactions({principal: 'ST000000000000000000002AMW42H',});
Using WebSockets
import { connectWebSocketClient } from '@stacks/blockchain-api-client';const client = await connectWebSocketClient('ws://api.hiro.so/');const sub = await client.subscribeAddressTransactions(contractCall.txId, event => {console.log(event);});await sub.unsubscribe();