opendatasoft_explore_api/
lib.rs

1//! `opendatasoft_explore_api` is an Opendatasoft Explore API v2 client library.
2//!
3//! It allows to query open data portals from public administrations and companies
4//! to get information about datasets metadata and records.
5//!
6//! # Example
7//!
8//! The library is compatible with data.economie.gouv.fr, the "portail des données ouvertes"
9//! from the France agency for economy. Let's query information about their FANTOIR file,
10//! a database with streets, neighborhoods or private residence names.
11//!
12//! ```rust,no_run
13//! use opendatasoft_explore_api::requests::ExploreApiEndPoint;
14//!
15//! static API_URL: &'static str = "https://data.economie.gouv.fr/api/v2";
16//! static DATASET_ID: &'static str = "fichier-fantoir-des-voies-et-lieux-dits";
17//!
18//! #[tokio::main]
19//! async fn main() {
20//!     let endpoint = ExploreApiEndPoint::new(API_URL);
21//!
22//!     let dataset = endpoint.get_dataset_information(DATASET_ID).await;
23//!     println!("{:?}", dataset);
24//! }
25//! ```
26//!
27//! # Asynchronous code
28//!
29//! The library uses under the hood Reqwest to perform async HTTP calls.
30//!
31//! Our code is tested with Tokio, but you can use the async runtime of your choice.
32//!
33//! # Under the hood
34//!
35//! Reqwest is used to run queries as HTTP client.
36//!
37//! Serde converts JSON responses into the structures defined in schema module.
38//!
39//! # Library organization
40//!
41//! The crate offers is organization in two modules:
42//!
43//! * In requests module, the [`ExploreApiEndPoint`](./requests/struct.ExploreApiEndPoint.html)
44//!   allows to prepare an HTTP client and define the end-point API URL;
45//!
46//! * In schema module, the structs represent datatypes used by the API responses.
47//!
48//! The requests are documented in `ExploreApiEndPoint`. From there, you'll always have a link
49//! to the schema used, as the return type of the method.
50
51pub mod schema;
52pub mod requests;
53
54pub use reqwest::Response as ApiHttpResponse;