fred_rs/
lib.rs

1#![crate_name = "fred_rs"]
2#![doc(html_root_url = "https://docs.rs/fred-rs/0.1.1")]
3
4//! **fred-rs** is a simple interface for accessing the Federal Reserve Bank of St. Louis's FRED API.
5//! 
6//! # FRED (Federal Reserve Economic Data)
7//! FRED is a large online database of economic data hosted by the Federal
8//! Reserve Bank of St. Louis.  The website currently hosts approximately 
9//! "672,000 US and international time series from 89 sources."
10//! 
11//! Access to the raw data is available through the FRED API.  **fred-rs** is 
12//! an intermediate layer between the HTTPS client and the user 
13//! application.  Requests to the FRED API are made through structured calls 
14//! to the fred_rs FredClient and data is returned as usable data objects 
15//! (structs).
16//! 
17//! # Usage
18//! ```
19//! use fred_rs::client::FredClient;
20//! use fred_rs::series::observation::{Builder, Units, Frequency, Response};
21//! 
22//! // Create the client object
23//! let mut c = match FredClient::new() {
24//!     Ok(c) => c,
25//!     Err(msg) => {
26//!         println!("{}", msg);
27//!         return
28//!     },
29//! };
30//! 
31//! // Create the argument builder
32//! let mut builder = Builder::new();
33//! 
34//! // Set the arguments for the builder
35//! builder
36//!     .observation_start("2000-01-01")
37//!     .units(Units::PCH)
38//!     .frequency(Frequency::M);
39//! 
40//! // Make the request and pass in the builder to apply the arguments
41//! let resp: Response = match c.series_observation("GNPCA", Some(builder)) {
42//!     Ok(resp) => resp,
43//!     Err(msg) => {
44//!         println!("{}", msg);
45//!         return
46//!     },
47//! };
48//! ```
49//! 
50//! ### Request Parameters
51//! All endpoints use the builder approach to construct the API URL.  Each 
52//! builder method corresponds to a paramter that can be added to the API 
53//! request. 
54//! 
55//! In the example above, three parameters are added to the request, 
56//! observation_start, units and frequency.  The [FRED API Documentation](https://research.stlouisfed.org/docs/api/fred/#General_Documentation) 
57//! explains the possible parameters for each endpoint.  Required paramters 
58//! (except the `tag_names` paramter) are passed to the client function 
59//! itself.  In the example, series_id is a required paramter and is passed 
60//! directly to the client function as `"GNPCA"`.  The `tag_names` parameter 
61//! available on some endpoints accepts a list of arguments, so it is easier to
62//!  pass this argument to the builder.
63//! 
64//! # API Key
65//! Developers need to request an API Key in order to access FRED.  This 
66//! can be done at [https://research.stlouisfed.org/docs/api/api_key.html](https://research.stlouisfed.org/docs/api/api_key.html).
67//! 
68//! **fred-rs** looks for the `FRED_API_KEY` environment variable by 
69//! default.  The environment variable can be set with the following 
70//! line in Bash.
71//! ```bash
72//! export FRED_API_KEY=abcdefghijklmnopqrstuvwxyz123456
73//! ```
74//! 
75//! Alternatively, the `FredClient.with_key()` function allows the key to be 
76//! set from a string reference.
77//! ```rust
78//! use fred_rs::client::FredClient;
79//! 
80//! let mut client = match FredClient::new() {
81//!     Ok(c) => c,
82//!     Err(msg) => {
83//!         println!("{}", msg);
84//!         return
85//!     },
86//! };
87//! 
88//! client.with_key("abcdefghijklmnopqrstuvwxyz123456");
89//! ```
90//! 
91//! # Issues/Bugs/Improvments/Help/Questions
92//! If you discover any issues or bugs, want to suggest any improvements, or 
93//! have questions about the crate, feel free to open a GitHub issue or email 
94//! me directly at [matthewdsabo@gmail.com](mailto:matthewdsabo@gmail.com) with 
95//! **fred-rs** in the subject line.
96//! 
97//! #### License
98//! 
99//! Licensed under either of Apache License, Version
100//! 2.0 or MIT license at your option.
101//! 
102//! Unless you explicitly state otherwise, any contribution intentionally 
103//! submitted for inclusion in this crate by you, as defined in the Apache-2.0 
104//! license, shall be dual licensed as above, without any additional terms or 
105//! conditions.
106
107pub mod client;
108pub mod category;
109pub mod releases;
110pub mod release;
111pub mod series;
112pub mod tags;
113pub mod related_tags;
114pub mod sources;
115pub mod source;
116
117mod error;