Rust SDK
Last updated · Changelog · OpenAPI spec · Markdown
Our official Rust SDK provides memory-safe, high-performance access to the ShopSavvy Data API with full type safety.
Installation
[dependencies]
shopsavvy-sdk = "1.0"
tokio = { version = "1.0", features = ["full"] }Quick Start
use shopsavvy_sdk::{Client, Result};
#[tokio::main]
async fn main() -> Result<()> {
// Create a new client
let client = Client::new("ss_live_your_api_key_here")?;
// Get product details
let product = client.get_product_details("012345678901").await?;
println!("Product: {}", product.data.name);
// Get current offers
let offers = client.get_current_offers("012345678901", None).await?;
for offer in offers.data {
println!("{}: ${:.2}", offer.retailer, offer.price);
}
// Get price history
let history = client.get_price_history(
"012345678901",
"2024-01-01",
"2024-01-31",
None
).await?;
Ok(())
}Error Handling
use shopsavvy_sdk::{Client, Error};
match client.get_product_details("invalid-id").await {
Ok(product) => println!("Found: {}", product.data.name),
Err(Error::NotFound) => println!("Product not found"),
Err(Error::RateLimit) => println!("Rate limit exceeded"),
Err(Error::Authentication) => println!("Invalid API key"),
Err(e) => println!("Other error: {}", e),
}Features
- Memory safe with zero-cost abstractions
- Full async/await support with tokio
- Strongly typed with serde serialization
- Comprehensive error handling
- Built-in rate limiting
- Support for Rust 1.70+
Was this page helpful?