UniSat Open API TypeScript SDK
npm install @unisat/open-api> TypeScript SDK for UniSat Open API
``bash`
npm install @unisat/open-api
`bash`
yarn add @unisat/open-api
`bash`
pnpm add @unisat/open-api
`typescript
import { createClient } from '@unisat/open-api';
const client = createClient({
apiKey: 'your-api-key',
});
// Get blockchain info
const info = await client.blockchain.getBlockchainInfo();
console.log(info);
// Get recommended fees
const fees = await client.fees.getRecommendedFees();
console.log(fees);
// Get block by height
const block = await client.blocks.getBlockByHeight({ height: 800000 });
console.log(block);
`
`typescript
import { createClient } from '@unisat/open-api';
// For testnet
const testnetClient = createClient({
baseUrl: 'https://open-api-testnet.unisat.io',
apiKey: 'your-api-key',
});
`
`typescript
import axios from 'axios';
import { createClient } from '@unisat/open-api';
const axiosInstance = axios.create({
timeout: 10000,
});
const client = createClient({
axios: axiosInstance,
});
`
| Network | URL |
|---------|-----|
| Bitcoin Mainnet | https://open-api.unisat.io |https://open-api-staging.unisat.io
| Bitcoin Staging | |https://open-api-testnet.unisat.io
| Bitcoin Testnet | |https://open-api-testnet4.unisat.io
| Bitcoin Testnet4 | |https://open-api-signet.unisat.io
| Bitcoin Signet | |https://open-api-fractal.unisat.io
| Fractal Mainnet | |https://open-api-fractal-testnet.unisat.io
| Fractal Testnet | |
The SDK is organized into modules based on API tags:
- blockchain - Blockchain infoblocks
- - Block datatransactions
- / tx - Transaction dataaddresses
- / address - Address info, balance, UTXOinscriptions
- / inscription - Inscription databrc20
- - BRC-20 token operationsrunes
- - Runes operationsalkanes
- - Alkanes operationsmarketplace
- - Marketplace operations
- And more...
To regenerate the API types from the OpenAPI spec:
`bash`
npm run generate
This script uses the latest OpenAPI spec from ../../open-api/auto-generated/swagger/openapi-swagger.yaml.
`bash`
npm run build
`bash``
npm run dev
Apache-2.0