Openweather is an unofficial thin wrapper around OpenWeatherMaps API for requesting current and historical weather data
Useful links: - OpenWeatherMap API's - Registering an API key
To request weather data a LocationSpecifier
needs to be defined for the location of interest. The available methods of specifiying a location are:
- CityAndCountryName ({city: "CITY_NAME", country: "COUNTRY_CODE"}
)
- CityId (CITY_ID_CODE
)
- Coordinates ({lat: LATITUDE, lon: LONGITUDE}
)
- ZipCode ({zip: "ZIP_CODE", country: "COUNTRY_CODE"}
)
- BoundingBox ({lon_left: LEFT_LONGITUDE, lat_bottom: BOTTOM_LATITUDE, lon_right: RIGHT_LONGITUDE, lat_top: TOP_LATITUDE}
)
- Circle ({lat: CENTER_LATITUDE, lon: CENTER_LONGITDE, count: NUMBER_OF_CITIES_OF_INTEREST}
)
- CityIds ([CITY_ID_1, CITY_ID_2]
)
Once a LocationSpecifier
has been created it can be used to querry any of available API endpoints:
- getcurrentweather
- get5dayforecast
- get16dayforecast
- gethistoricaldata
- getaccumulatedtemperaturedata
- getaccumulatedprecipitationdata
- getcurrentuvindex
- getforecastuvindex
- gethistoricaluv_index
An example of querrying the current temperature in Minneapolis, MN: ```rust extern crate openweather;
use openweather::LocationSpecifier; static APIKEY: &str = "YOURAPIKEYHERE";
fn main() { let loc = LocationSpecifier::CityAndCountryName{city:"Minneapolis", country:"USA"}; let weather = openweather::getcurrentweather(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)