Crate awattar_api

Source
Expand description

§awattar-api – Rust client for the awattar price API

This crates is an API client for the awattar price API.

The API of this crate is currently not considered stable and is likely to change in future releases.

§Usage

For a full example have a look at the examples/-directory.

Add awattar-api to you dependencies:

[dependencies]
awattar-api = "0.2.0"

Querying prices is simple:

use awattar_api::*;
use chrono::Utc;

#[tokio::main]
async fn main() {
    let date = Utc::today().naive_local();

    let prices = PriceData::query_date(AwattarZone::Germany, date)
        .await
        .unwrap();

    for slot in prices.slots_iter() {
        println!(
            "{} - {}: {:.02} €/kWh",
            slot.start(),
            slot.end(),
            slot.price_cents_per_mwh() as f32 / 100_000.00
        );
    }
}

§License

This crate is licensed under the MIT license.

Structs§

PriceData
Holds a set of price slots and provides some utility functions for working with price data.
PriceSlot
A single price slot.

Enums§

AwattarError
Common error enum for this crate.
AwattarZone
Zone for awattar prices.

Functions§

query_pricesDeprecated
Query prices from the API in the given zone with an optional start and end DateTime.
query_prices_nowDeprecated
This is a shortcut for query_prices::<Utc>(zone, None, None).