Constant weather_cli::constants::GEOLOCATION_API_URL

source ·
pub const GEOLOCATION_API_URL: &str = "http://api.openweathermap.org/geo/1.0/direct?q={QUERY}&limit=10&appid={API_KEY}";
Expand description

§Geocoding API

Geocoding API is a simple tool that we have developed to ease the search for locations while working with geographic names and coordinates. API Documentation: https://openweathermap.org/api/geocoding-api

  • {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");