#weather #api #openweather #openweathermaps


A rust crate wrapping openweather’s API into a simple easy to use interface

1 unstable release

0.0.1 Oct 7, 2018

#10 in #weather

Download history 4/week @ 2018-11-05 6/week @ 2018-11-12 2/week @ 2018-11-19 2/week @ 2018-11-26 2/week @ 2018-12-03 4/week @ 2018-12-10 3/week @ 2018-12-17 9/week @ 2018-12-24 1/week @ 2018-12-31 5/week @ 2019-01-14 2/week @ 2019-01-21 3/week @ 2019-01-28

6 downloads per month

MIT license Custom license

376 lines

openweather   Latest Version

Openweather is an unofficial thin wrapper around OpenWeatherMaps API for requesting current and historical weather data

Useful links:

How to use

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})
  • CityIds ([CITY_ID_1, CITY_ID_2])

Once a LocationSpecifier has been created it can be used to querry any of available API endpoints:

  • get_current_weather
  • get_5_day_forecast
  • get_16_day_forecast
  • get_historical_data
  • get_accumulated_temperature_data
  • get_accumulated_precipitation_data
  • get_current_uv_index
  • get_forecast_uv_index
  • get_historical_uv_index

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)


~11K SLoC