rparif

Crates.iorparif
lib.rsrparif
version0.1.1
sourcesrc
created_at2020-05-23 11:36:02.033232
updated_at2022-06-18 06:31:40.313934
descriptionLibrary that allow to access AirParif services.
homepagehttps://github.com/Dalvany/r-parif
repositoryhttps://github.com/Dalvany/r-parif
max_upload_size
id244848
size90,750
(Dalvany)

documentation

https://docs.rs/rparif/

README

R-Parif

A Rust library that allows access Airparif indice pollution API for Ile-de-France (France).
It needs an API key to work.

API

It allows access to :

  • indice : it provides the global pollution index
  • indiceJour : it returns global and per pollutant indices for previous, current or next day
  • idxville : returns indice and pollutant for given cities for previous, current and next day
  • episode : returns pollution alerts

Documentation can be found here

Serde

With serde feature, data structures implemente Serde's Serialize and Deserialize

Examples

Cargo.toml

[dependencies]
rparif = "0.1"
extern crate rparif;

use rparif::client::RParifClient;
use rparif::error::RParifError;

fn main() -> Result<(), RParifError> {
    let client = RParifClient::new("my-api-key");
    let indices = client.index()?;
    for index in indices.into_iter() {
        println!("{}", index);
    }
    Ok(())
}

With a valid API key :

2020-05-17 (city : None) : ["global"] = 53 (map : Some("https://www.airparif.asso.fr/services/cartes/indice/date/hier"))
2020-05-18 (city : None) : ["global"] = 49 (map : Some("https://www.airparif.asso.fr/services/cartes/indice/date/jour"))
2020-05-19 (city : None) : ["global"] = 49 (map : Some("https://www.airparif.asso.fr/services/cartes/indice/date/demain"))

With an invalid API key :

Error : Some(CallError { url: "https://www.airparif.asso.fr/services/api/1.1/indice?key=wrong-api", body: "{\"erreur\":\"Cl\\u00e9 invalide\"}", status: 403 })

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Commit count: 13

cargo fmt