sobry-api 0.1.0

Async Rust client for the Sobry.co electricity price API v2
Documentation

sobry-api

An asynchronous Rust client for the Sobry electricity price API v2, made by SiSol PRO, a good french company that helps you create "Opérations d'autoconsommation collectives (ACC)" in France :).

use chrono::NaiveDate;
use sobry_api::{Client, DailyPricesRequest, Granularity, TaxMode};

#[tokio::main]
async fn main() -> Result<(), sobry_api::Error> {
    let client = Client::new(std::env::var("SOBRY_API_KEY").unwrap())?;
    let request = DailyPricesRequest::new()
        .day(NaiveDate::from_ymd_opt(2026, 6, 12).unwrap())
        .days(3)
        .granularity(Granularity::QuarterHour)
        .tax_mode(TaxMode::IncludingTax);

    for point in client.daily_prices(&request).await? {
        println!("{} {}: {:.5} EUR/kWh ({:?}){}", point.date, point.time,
            point.price, point.color_label,
            if point.estimated { " forecast" } else { "" });
    }
    Ok(())
}

The key is sent as a sensitive Authorization: Bearer ... header and is redacted from the client's debug output. It identifies one Sobry contract and needs the price:read scope.

The API accepts a maximum days value of 10. Since the range is inclusive, days(3) returns the first day through J+3 (four days total).

Run the included example with:

SOBRY_API_KEY=sob_apikey_... cargo run --example basic

Set SOBRY_DAY=YYYY-MM-DD to request a particular starting date; otherwise the API uses today.

License

Licensed under either Apache License 2.0 or MIT, at your option.