Crates.io | strompris |
lib.rs | strompris |
version | 0.4.1 |
source | src |
created_at | 2024-07-19 19:58:19.254918 |
updated_at | 2024-07-20 18:15:11.485869 |
description | A simple wrapper of the Strømpris-API from https://hvakosterstrommen.no |
homepage | |
repository | https://github.com/erlingv-chr/strompris/ |
max_upload_size | |
id | 1309038 |
size | 22,721 |
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.
Run cargo add strompris
to add this crate to your Cargo.toml
file.
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);
}
}