获取OpenWeatherMap API的当前天气数据、预报和天气信息。当用户询问天气、温度、预报或任何相关问题时使用。
Get your free API key from: https://home.openweathermap.org/api_keys
Store your API key securely (the skill checks these in order):
$OPENWEATHERMAP_API_KEY~/.openweathermap (should contain just the API key, one line)text
GET https://api.openweathermap.org/data/2.5/weather?q={city},{country_code}&appid={API_KEY}&units={units}
text
GET https://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&appid={API_KEY}&units={units}
ParameterRequiredDescriptionappidYesYour OpenWeatherMap API keyqYes*City name, state code, country code (e.g., "London,UK" or "Stamford,CT,US")latYes*LatitudelonYes*LongitudeunitsNometric, imperial, or standard. Default: standardlangNoLanguage code for description (e.g., en, es, fr, de)
Units:
metric = Celsius, m/s, hPaimperial = Fahrenheit, mph, hPa (use for US locations)standard = Kelvin, m/s, hPaLocation Tips for US:
Stamford,CT,US or full name Stamford,Connecticut,USbash
curl "https://api.openweathermap.org/data/2.5/weather?q=London,UK&appid=YOUR_API_KEY&units=metric"
bash
curl "https://api.openweathermap.org/data/2.5/weather?q=Stamford,CT,US&appid=YOUR_API_KEY&units=imperial"
bash
curl "https://api.openweathermap.org/data/2.5/weather?lat=41.05&lon=-73.54&appid=YOUR_API_KEY&units=imperial"
main.temp - Temperature (Celsius/Fahrenheit/Kelvin based on units)main.feels_like - Perceived temperaturemain.humidity - Humidity %main.pressure - Atmospheric pressure (hPa)wind.speed - Wind speed (m/s or mph based on units)wind.deg - Wind direction (degrees)wind.gust - Wind gusts (if available)clouds.all - Cloudiness %weather[0].main - Weather condition (Rain, Snow, Clouds, Clear, etc.)weather[0].description - Detailed descriptionvisibility - Visibility in meterssys.sunrise / sys.sunset - Unix timestampsname - Location nametimezone - Shift from UTC in secondsUse imperial units (Fahrenheit, mph) for US users:
1 inHg = 33.86 hPa24-hour time: Convert Unix timestamps to 24-hour format (e.g., 18:45 instead of 6:45 PM)
Example formatting:
text
🌡️ Temp: 45°F (feels like 40°F)
💧 Humidity: 65%
💨 Wind: 12 mph NW
🌅 Sunrise: 06:32
🌇 Sunset: 18:45
text
GET https://api.openweathermap.org/data/2.5/forecast?q={city}&appid={API_KEY}&units=imperial
Returns forecast data in 3-hour intervals for 5 days.