unisat-api v1.2.0
UniSat API Client π
π UniSat API Client is an open-source TypeScript/JavaScript client library based on the UniSat API. It provides a simple and easy-to-use interface to interact with various services of UniSat, including blockchain queries, transactions, inscriptions, BRC-20 tokens, and more.
β¨ Features
- πΌ Complete encapsulation of all UniSat API functions
- π¦ Supports TypeScript with type definitions
- π Easy-to-use Promise-based interface
- βοΈ Built-in request rate limiting and error handling
- π§ Supports custom configurations (network, base URL, etc.)
π¦ Installation
Using npm:
npm install unisat-api
Or using yarn:
yarn add unisat-api
π Quick Start
import UnisatApiClient from 'unisat-api';
const client = new UnisatApiClient({
apikey: 'YOUR_API_KEY',
network: 'mainnet'
});
// π Get blockchain information
client.blocks.getBlockchainInfo().then(info => {
console.log(info);
});
// π° Get address balance
client.address.getAddressBalance('bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh').then(balance => {
console.log(balance);
});
π οΈ API Overview
The UniSat API client provides the following main modules:
- πͺ
runes
: Runes-related operations - π
market
: Market data queries - π§±
blocks
: Blockchain information queries - π
brc20swap
: BRC-20 token swaps - π¦
address
: Address-related operations - ποΈ
inscription
: Inscription operations - π
inscriptions
: Inscription queries - πΈ
transaction
: Transaction-related operations
Each module contains multiple methods for interacting with the corresponding UniSat API endpoints.
π Documentation
For detailed explanations of each module and method, please refer to our API Documentation.
βοΈ Configuration Options
When creating an instance of UnisatApiClient
, you can pass the following configuration options:
apikey
: Your UniSat API key (required)network
: The network to connect to ('mainnet' or 'testnet', default is 'mainnet')baseURL
: Custom API base URL (optional)
β οΈ Error Handling
All API methods return a Promise. It is recommended to use a try/catch block or the .catch()
method to handle any potential errors.
try {
const balance = await client.address.getAddressBalance('bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh');
console.log(balance);
} catch (error) {
console.error('Error fetching balance:', error);
}
π Contribution Guidelines
We welcome and appreciate all forms of contributions. If you'd like to contribute to the project, please follow these steps:
- π΄ Fork the repository
- πΏ Create your feature branch (
git checkout -b feature/AmazingFeature
) - π» Commit your changes (
git commit -m 'Add some AmazingFeature'
) - π Push to the branch (
git push origin feature/AmazingFeature
) - π Open a Pull Request
Before submitting a Pull Request, please ensure your code adheres to our coding standards and passes all tests.
π License
This project is licensed under the MIT License. For more details, please see the LICENSE file.
π Related Links
- π UniSat Official Website
- π UniSat API Documentation
- π οΈ UniSat Developer Center
π¬ Contact Us
If you have any questions or suggestions, please contact us through:
- π¬ Submitting a GitHub Issue
- βοΈ Sending an email to your-email@example.com
Thank you for using the UniSat API Client! π