strompris

Crates.iostrompris
lib.rsstrompris
version0.4.1
sourcesrc
created_at2024-07-19 19:58:19.254918
updated_at2024-07-20 18:15:11.485869
descriptionA simple wrapper of the Strømpris-API from https://hvakosterstrommen.no
homepage
repositoryhttps://github.com/erlingv-chr/strompris/
max_upload_size
id1309038
size22,721
(erlingv-chr)

documentation

README

Strømpris

This crate is a wrapper around the Strømpris-API hosted on https://hvakostersttrommen.no.

The crate offers both async and blocking versions of the client, as well as a strongly typed model of the response objects.

Documentation

https://docs.rs/strompris

Usage

Run cargo add strompris to add this crate to your Cargo.toml file.

Example

use strompris::blocking::Strompris;
use strompris::{PriceRegion, Date};

fn main() {
    let date = Date::from_ymd_opt(2024, 1, 31).unwrap();
    let client = Strompris::default();
    let prices = client.get_prices(date, PriceRegion::NO1).unwrap();
    for price in prices.iter() {
        println!("From: {}", price.time_start.time());
        println!("To: {}", price.time_end.time());
        println!("Price: {:.2} NOK\n", price.nok_per_kwh);
    }
}
Commit count: 0

cargo fmt