1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
//! # Ambient Weather API
//!
//! `ambient_weather_api` is a collection of functions for downloading current and historical data from the Ambient Weather API. It features built in support for choosing which device you want to pull data from, and has safety measures built in to avoid hitting Ambient Weather's rate limits.
//!
//! To learn more about how the Ambient Weather API works, and to obtain the required API and Application keys to use this creat, check out the [Ambient Weather API Documentation](https://ambientweather.docs.apiary.io).
//!
//! In order to use this API, you will need to look over the [list of device parameters](https://github.com/ambient-weather/api-docs/wiki/Device-Data-Specs) that Ambient Weather offers. Not all device parameters may be used, so make sure you are calling one that is associated with your device.
//!
//! Currently, this Rust crate is only capable of utilizing the Ambient Weather REST API. Support for their Realtime Socket.IO API will come at a later date.
//!
//! # Getting Started
//!
//! To get started with pulling in the latest weather data from your Ambient Weather device, simply follow the example below:
//!
//! ```
//! use ambient_weather_api::*;
//!
//! fn main() {
//!
//! let api_credentials = AmbientWeatherAPICredentials {
//! api_key: String::from("Your API Key"),
//! app_key: String::from("Your Application Key"),
//! device_id: 0,
//! use_new_api_endpoint: false,
//! };
//!
//! let latest_data = get_latest_aw_device_data(api_credentials);
//!
//! println!("{}", latest_data["tempf"]);
//! }
//! ```
use reqwest;
use ;
use ;
/// The struct for holding the API and App keys, the device idea, and whether or not to use the new API endpoint or not.
/// A private function for crafting the appropriate Ambient Weather API URL.
/// Advanced: Gets the latest raw device data from the Ambient Weather REST API.
///
/// Unless you have a specific need to access the raw device data, I would not recommend using this, due to the messy nature of the output.
/// Advanced: Gets the historical raw data from the Ambient Weather REST API.
///
/// Unless you have a specific need to access the raw device data, I would not recommend using this, due to the messy nature of the output.
/// Gets the latest device data from the Ambient Weather API.
///
/// Currently does so in a blocking manner. Asyncronus support will be added eventually.
///
/// In order to use this API, you will need to look over the [list of device parameters](https://github.com/ambient-weather/api-docs/wiki/Device-Data-Specs) that Ambient Weather offers. Not all device parameters may be used, so make sure you are calling one that is associated with your device.
///
/// # Examples
///
/// ```
/// use ambient_weather_api::get_latest_aw_device_data;
///
/// fn main() {
///
/// let api_credentials = AmbientWeatherAPICredentials {
/// api_key: String::from("Your API Key"),
/// app_key: String::from("Your Application Key"),
/// device_id: 0,
/// use_new_api_endpoint: false,
/// };
///
/// let latest_data = get_latest_aw_device_data(api_credentials);
///
/// println!("{}", latest_data["tempf"]);
/// }
/// ```
/// Gets the historic device data from the Ambient Weather API.
///
/// Currently does so in a blocking manner. Asyncronus support will be added eventually.
///
/// In order to use this API, you will need to look over the [list of device parameters](https://github.com/ambient-weather/api-docs/wiki/Device-Data-Specs) that Ambient Weather offers. Not all device parameters may be used, so make sure you are calling one that is associated with your device.
///
/// # Examples
///
/// ```
/// use ambient_weather_api::get_historic_aw_device_data;
///
/// fn main() {
///
/// let api_credentials = AmbientWeatherAPICredentials {
/// api_key: String::from("Your API Key"),
/// app_key: String::from("Your Application Key"),
/// device_id: 0,
/// use_new_api_endpoint: false,
/// };
///
/// let historic_data = get_historic_aw_device_data(api_credentials);
///
/// println!("{}", historic_data[0]["tempf"]);
/// }
/// ```