unisat-api
v1.2.0
Published
Unisat API Client
Downloads
24
Readme
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
📬 Contact Us
If you have any questions or suggestions, please contact us through:
- 💬 Submitting a GitHub Issue
- ✉️ Sending an email to [email protected]
Thank you for using the UniSat API Client! 🚀