| Crates.io | rain-sdk |
| lib.rs | rain-sdk |
| version | 1.2.0 |
| created_at | 2025-11-14 03:04:13.607326+00 |
| updated_at | 2025-11-21 09:11:59.639335+00 |
| description | A modern, type-safe Rust SDK for the Rain xyz API |
| homepage | |
| repository | https://github.com/yezz123/rain-rust-sdk |
| max_upload_size | |
| id | 1932188 |
| size | 362,923 |

A modern, type-safe Rust SDK for the Rain Cards API.
Add this to your Cargo.toml:
[dependencies]
rain-sdk = { version = "0.1.0", features = ["async"] }
For blocking/sync operations:
[dependencies]
rain-sdk = { version = "0.1.0", features = ["sync"] }
use rain_sdk::{RainClient, Config, Environment, AuthConfig};
use rain_sdk::models::applications::InitiateUserApplicationRequest;
use uuid::Uuid;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create configuration for dev environment
let config = Config::new(Environment::Dev);
// Create authentication config with API key
let auth = AuthConfig::with_api_key("your-api-key".to_string());
// Create the client
let client = RainClient::new(config, auth)?;
// Initiate a user application
let request = InitiateUserApplicationRequest {
first_name: "John".to_string(),
last_name: "Doe".to_string(),
email: "john@example.com".to_string(),
wallet_address: None,
};
let application = client.initiate_user_application(&request).await?;
println!("Application ID: {}", application.id);
Ok(())
}
use rain_sdk::{RainClient, Config, Environment, AuthConfig};
use rain_sdk::models::applications::InitiateUserApplicationRequest;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = Config::new(Environment::Dev);
let auth = AuthConfig::with_api_key("your-api-key".to_string());
let client = RainClient::new(config, auth)?;
let request = InitiateUserApplicationRequest {
first_name: "John".to_string(),
last_name: "Doe".to_string(),
email: "john@example.com".to_string(),
wallet_address: None,
};
let application = client.initiate_user_application_blocking(&request)?;
println!("Application ID: {}", application.id);
Ok(())
}
The SDK supports API key authentication:
let auth = AuthConfig::with_api_key("your-api-key".to_string());
See the examples directory for usage examples:
Run an example:
cargo run --example signup_consumer --features async
The SDK provides 100% coverage of the Rain Issuing API, with all 71 non-deprecated endpoints fully implemented and aligned with the OpenAPI specification.
The SDK uses a comprehensive error type system with detailed HTTP status codes:
use rain_sdk::error::RainError;
match client.get_user_application(&user_id).await {
Ok(application) => println!("Success: {:?}", application),
Err(RainError::ApiError { status, response }) => {
println!("API error (status {}): {}", status, response);
// Common status codes:
// - 400: Invalid request
// - 401: Invalid authorization
// - 403: Forbidden
// - 404: Not found
// - 409: Conflict
// - 423: Locked
// - 500: Internal server error
},
Err(RainError::HttpError(err)) => println!("HTTP error: {}", err),
Err(RainError::AuthError(msg)) => println!("Auth error: {}", msg),
Err(e) => println!("Other error: {}", e),
}
// Dev (default)
let config = Config::new(Environment::Dev);
// Production
let config = Config::new(Environment::Production);
// Custom URL
let config = Config::new(Environment::Custom(
url::Url::parse("https://api.custom.com/v1")?
));
let config = Config::new(Environment::Dev)
.with_timeout(60) // 60 second timeout
.with_user_agent("my-app/1.0".to_string())
.with_logging(true);
default: Enables async support with rustls-tlsasync: Async/await support (requires tokio)sync: Blocking/synchronous operationsrustls-tls: Use rustls for TLS (default)native-tls: Use native TLS implementationgzip: Enable gzip compressionjson: JSON serialization support (enabled by default)Licensed under the MIT license (LICENSE).
Contributions are welcome! Please feel free to submit a Pull Request.