The official Rust SDK for BlindPay — Stablecoin API for global payments.
cargo add blindpayOr add it to your Cargo.toml:
[dependencies]
blindpay = "0.1"The SDK is async and runtime-agnostic; the examples below use Tokio:
[dependencies]
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }To get started, you will need both your API key and your instance id. You can obtain them from the BlindPay dashboard at https://app.blindpay.com/instances/{instanceId}/api-keys.
use blindpay::BlindPay;
let blindpay = BlindPay::new("your-api-key-here", "your-instance-id-here")?;
# let _ = blindpay;
# Ok::<(), blindpay::Error>(())Note All API calls use the provided API key and instance id.
use blindpay::BlindPay;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let blindpay = BlindPay::new("your-api-key-here", "your-instance-id-here")?;
let rails = blindpay.available.get_rails().await?;
for rail in &rails {
println!("{} ({}) in {}", rail.label, rail.value, rail.country);
}
Ok(())
}Every method returns a Result, so you handle success and failure with ordinary Rust control flow — ?, match, or the Result combinators.
- Success resolves to the typed response (for example
Vec<RailEntry>orCustomer). - Failure is a
blindpay::Error. API responses with a non-2xx status areError::Api, which carries the HTTPstatus, the APImessage, and the raw responsebody. Other variants cover transport (Error::Http), response decoding (Error::Decode), and client configuration (Error::Config).
Always handle the Result. Match on the error to react to specific cases:
use blindpay::{BlindPay, Error};
#[tokio::main]
async fn main() {
let blindpay = BlindPay::new("your-api-key-here", "your-instance-id-here").unwrap();
match blindpay.available.get_rails().await {
Ok(rails) => println!("Success: {} rails", rails.len()),
Err(Error::Api(err)) => eprintln!("API error {}: {}", err.status, err.message),
Err(err) => eprintln!("Error: {err}"),
}
}Use the builder for a custom timeout, base URL, or a preconfigured reqwest::Client:
use std::time::Duration;
use blindpay::BlindPay;
let blindpay = BlindPay::builder("your-api-key-here", "your-instance-id-here")
.timeout(Duration::from_secs(10))
.build()?;
# let _ = blindpay;
# Ok::<(), blindpay::Error>(())rustls-tls(default) — TLS via rustls.native-tls— TLS via the platform's native library.
For detailed API documentation, visit:
- 📧 Email: alves@blindpay.com
- 🐛 Issues: GitHub Issues
This project is licensed under the MIT License — see the LICENSE file for details.
Made with ❤️ by the BlindPay team