Crypto Pay API Client for Rust
A type-safe Rust client for the Crypto Bot API with async support.
Features
- Complete type safety with typestate builder pattern
- Async/await support
- Comprehensive error handling
- Built-in parameter validation
- Zero configuration
- Webhook support
- Full API coverage
Quick Start
Add to your Cargo.toml:
[]
= "0.2.1"
Basic Example
use *;
async
API Usage
All API methods follow a consistent builder pattern:
client.api_method
.optional_param
.execute
.await?
Creating Invoices
let invoice = client.create_invoice
.asset
.amount // No need for dec!() macro
.description
.payload
.execute
.await?;
Querying Invoices
let invoices = client.get_invoices
.asset
.invoice_ids
.count
.execute
.await?;
Deleting Invoices
let success = client.delete_invoice
.execute
.await?;
Creating Transfers
let transfer = client.transfer
.user_id
.asset
.amount // Flexible amount input
.spend_id
.comment
.execute
.await?;
Getting Balance
let balances = client.get_balance
.execute
.await?;
for balance in balances
Getting Exchange Rates
let rates = client.get_exchange_rates
.execute
.await?;
Getting Statistics
let stats = client.get_stats
.start_at
.end_at
.execute
.await?;
API Coverage
Invoices
- Create invoice (
create_invoice) - Get invoices (
get_invoices) - Delete invoice (
delete_invoice)
Transfers
- Transfer (
transfer) - Get transfers (
get_transfers)
Checks
- Create check (
create_check) - Get checks (
get_checks) - Delete check (
delete_check)
Other Features
- Get balance (
get_balance) - Get exchange rates (
get_exchange_rates) - Get currencies (
get_currencies) - Get app info (
get_me) - Get statistics (
get_stats)
Webhook Handling
use *;
async
See examples/axum_webhook.rs for a complete example using axum.
Custom Configuration
let client = builder
.api_token
.base_url
.timeout
.build?;
Error Handling
The library provides detailed error types:
match client.get_balance.execute.await
Documentation
Contributing
Contributions are welcome! Please check out our Contributing Guide.
License
This project is licensed under the MIT License - see the LICENSE file for details.