Crates.io | openweather |
lib.rs | openweather |
version | 0.0.1 |
source | src |
created_at | 2018-10-07 06:52:28.76892 |
updated_at | 2018-10-07 06:52:28.76892 |
description | A rust crate wrapping openweather's API into a simple easy to use interface |
homepage | |
repository | https://github.com/BroderickCarlin/openweather |
max_upload_size | |
id | 88487 |
size | 18,463 |
Openweather is an unofficial thin wrapper around OpenWeatherMaps API for requesting current and historical weather data
Useful links:
To request weather data a LocationSpecifier
needs to be defined for the location of interest. The available methods of specifiying a location are:
{city: "CITY_NAME", country: "COUNTRY_CODE"}
)CITY_ID_CODE
){lat: LATITUDE, lon: LONGITUDE}
){zip: "ZIP_CODE", country: "COUNTRY_CODE"}
){lon_left: LEFT_LONGITUDE, lat_bottom: BOTTOM_LATITUDE, lon_right: RIGHT_LONGITUDE, lat_top: TOP_LATITUDE}
){lat: CENTER_LATITUDE, lon: CENTER_LONGITDE, count: NUMBER_OF_CITIES_OF_INTEREST}
)[CITY_ID_1, CITY_ID_2]
)Once a LocationSpecifier
has been created it can be used to querry any of available API endpoints:
An example of querrying the current temperature in Minneapolis, MN:
extern crate openweather;
use openweather::LocationSpecifier;
static API_KEY: &str = "YOUR_API_KEY_HERE";
fn main()
{
let loc = LocationSpecifier::CityAndCountryName{city:"Minneapolis", country:"USA"};
let weather = openweather::get_current_weather(loc, API_KEY).unwrap();
println!("Right now in Minneapolis, MN it is {}K", weather.main.temp);
}
openweather is licensed under the MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)