Function ambient_weather_api::get_latest_device_data
source · pub fn get_latest_device_data(
api_credentials: &AmbientWeatherAPICredentials
) -> WeatherData
Expand description
Gets the latest device data from the Ambient Weather API.
In order to use this API, you will need to look over the list of device parameters that Ambient Weather offers. Not all device parameters may be used, so make sure you are calling one that is associated with your device.
When calling the get_latest_device_data
function, you must pass the api_credentials as a reference (&api_credentials
), as this allows for it to be called multiple times elsewhere in a program if necessary.
Examples
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,
};
// Get the current temperature
let latest_data = get_latest_device_data(&api_credentials);
println!("The current temp is: {}F", latest_data.tempf.unwrap());
}