Skip to content

Latest commit

 

History

History
31 lines (23 loc) · 700 Bytes

README.md

File metadata and controls

31 lines (23 loc) · 700 Bytes

marketplacetf-api

Interface for marketplace.tf API endpoints.

use marketplacetf_api::{MarketplaceAPI, error::Error};

#[tokio::main]
async fn main() -> Result<(), Error> {
    let key = "key";
    let marketplacetf = MarketplaceAPI::new(key);
    let sales = marketplacetf.get_sales(10, None).await?;
    
    if let Some(sale) = sales.first() {
        let names = sale.items
            .iter()
            .map(|item| item.name.as_str())
            .collect::<Vec<_>>();
        
        println!("Sold {} for ${:.2}!", names.join(", "), f32::from(sale.earned_credit) / 100.0);
    } else {
        println!("You have not sold anything :(");
    }
    
    Ok(())
}

License

MIT