WEATHER_API_URL

Constant WEATHER_API_URL 

Source
pub const WEATHER_API_URL: &str = "https://api.openweathermap.org/data/2.5/weather?lat={LAT_VALUE}&lon={LON_VALUE}&appid={API_KEY}&units={UNIT}";
Expand description

§Current weather data

Access current weather data for any location on Earth! We collect and process weather data from different sources such as global and local weather models, satellites, radars and a vast network of weather stations. Data is available in JSON, XML, or HTML format. API Documentation: https://openweathermap.org/api/current

  • {lat_value}: Latitude value of the location.
  • {lon_value}: Longitude value of the location.
  • {api_key}: OpenWeatherMap API key.
  • {unit}: The desired measurement unit.

§Example Usage

let url = WEATHER_API_URL
    .replace("{LAT_VALUE}", "37.3361663")
    .replace("{LON_VALUE}", "-121.890591")
    .replace("{API_KEY}", "EXAMPLE_KEY")
    .replace("{UNIT}", "imperial");

assert_eq!(url, "https://api.openweathermap.org/data/2.5/weather?lat=37.3361663&lon=-121.890591&appid=EXAMPLE_KEY&units=imperial");