首页 > 其他分享 >Example of API call

Example of API call

时间:2024-09-26 15:52:34浏览次数:1  
标签:API Meteorological daily weather call units data Example

 

一键调用 API 3.0

×

OpenWeather
气象服务

丹·哈特与首席
气象学家丹·哈特和
他的团队交谈!

产品概念

使用我们的 OpenWeather One Call API 3.0可以轻松获取基本天气数据、短期和长期预报以及汇总天气数据。该产品旨在确保轻松从 Dark Sky API 迁移

One Call API 3.0 包含 4 个端点并提供对各种数据的访问:

One Call API 3.0 基于专有的OpenWeather 模型,每 10 分钟更新一次。因此,为了接收最准确、最新的天气数据,我们建议您每 10 分钟请求一次 One Call API 3.0。

请注意,One Call API 3.0仅包含在“One Call by Call”订阅中。此单独订阅包括每天 1,000 次免费呼叫,并且您只需为对此产品进行的 API 调用次数付费。请注意,您无需订阅任何其他 OpenWeather 订阅计划即可访问 One Call API 3.0。请在定价页面常见问题解答中查找更多详细信息。

如何开始

  1. 如果您还没有获得OpenWeather API 密钥,请注册OpenWeather 服务。
  2. 关注定价页面来了解价格详情。

    One Call API 3.0 仅包含在单独订阅中,您只需为对此产品进行的 API 调用次数付费。请在定价页面上查找更多详细信息。

  3. 一旦您订阅 One call API 3.0,该产品的每日 API 调用次数将默认为 2000 次。如果您想更改此限制,请前往个人帐户中的“计费计划”选项卡更新标准设置。您可以在常见问题解答中找到更多信息
  4. 选择所需的数据类型(当前和预测天气数据时间戳的天气数据每日汇总天气概览)并根据相关技术文档部分进行 API 调用,记得在每次调用中添加密钥。

当前和预报天气数据

要了解当前天气、1 小时分钟预报、48 小时每小时预报、8 天每日预报和政府天气警报,请使用本部分文档。

如果您对 One Call API 3.0 的其他功能感兴趣,请查看产品概念 以关注正确的部分。

如何进行 API 调用

API 调用

https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&exclude={part}&appid={API key}
参数
lat 必需的 纬度,十进制(-90;90)。如果您需要地理编码器自动将城市名称和邮政编码转换为地理坐标,反之亦然,请使用我们的地理编码 API
lon 必需的 经度,十进制(-180;180)。如果您需要地理编码器自动将城市名称和邮政编码转换为地理坐标,反之亦然,请使用我们的地理编码 API
appid 必需的 您的唯一 API 密钥(您始终可以在帐户页面的“API 密钥”选项卡下找到它)
exclude 选修的 通过使用此参数,您可以从 API 响应中排除部分天气数据。它应该是逗号分隔的列表(不带空格)。

可用值:

  • current
  • minutely
  • hourly
  • daily
  • alerts
units 选修的 测量单位。standardmetric单位imperial 可用。如果不使用units参数, standard将默认应用单位。了解详情
lang 选修的 您可以使用lang参数来获取您语言的输出。了解更多

API 调用示例

在进行 API 调用之前,请注意,One Call 3.0仅包含在“One Call by Call”订阅中。了解详情

If you you want to exclude some parts of the weather data from the API response please add exclude parameter to the API call like in the example below:

https://api.openweathermap.org/data/3.0/onecall?lat=33.44&lon=-94.04&exclude=hourly,daily&appid={API key}

If you do not need to exclude any of the weather data from the API response please use API call like in the example below:

https://api.openweathermap.org/data/3.0/onecall?lat=33.44&lon=-94.04&appid={API key}

Example of API response

Example of API response
                
{
   "lat":33.44,
   "lon":-94.04,
   "timezone":"America/Chicago",
   "timezone_offset":-18000,
   "current":{
      "dt":1684929490,
      "sunrise":1684926645,
      "sunset":1684977332,
      "temp":292.55,
      "feels_like":292.87,
      "pressure":1014,
      "humidity":89,
      "dew_point":290.69,
      "uvi":0.16,
      "clouds":53,
      "visibility":10000,
      "wind_speed":3.13,
      "wind_deg":93,
      "wind_gust":6.71,
      "weather":[
         {
            "id":803,
            "main":"Clouds",
            "description":"broken clouds",
            "icon":"04d"
         }
      ]
   },
   "minutely":[
      {
         "dt":1684929540,
         "precipitation":0
      },
      ...
   ],
   "hourly":[
      {
         "dt":1684926000,
         "temp":292.01,
         "feels_like":292.33,
         "pressure":1014,
         "humidity":91,
         "dew_point":290.51,
         "uvi":0,
         "clouds":54,
         "visibility":10000,
         "wind_speed":2.58,
         "wind_deg":86,
         "wind_gust":5.88,
         "weather":[
            {
               "id":803,
               "main":"Clouds",
               "description":"broken clouds",
               "icon":"04n"
            }
         ],
         "pop":0.15
      },
      ...
   ],
   "daily":[
      {
         "dt":1684951200,
         "sunrise":1684926645,
         "sunset":1684977332,
         "moonrise":1684941060,
         "moonset":1684905480,
         "moon_phase":0.16,
         "summary":"Expect a day of partly cloudy with rain",
         "temp":{
            "day":299.03,
            "min":290.69,
            "max":300.35,
            "night":291.45,
            "eve":297.51,
            "morn":292.55
         },
         "feels_like":{
            "day":299.21,
            "night":291.37,
            "eve":297.86,
            "morn":292.87
         },
         "pressure":1016,
         "humidity":59,
         "dew_point":290.48,
         "wind_speed":3.98,
         "wind_deg":76,
         "wind_gust":8.92,
         "weather":[
            {
               "id":500,
               "main":"Rain",
               "description":"light rain",
               "icon":"10d"
            }
         ],
         "clouds":92,
         "pop":0.47,
         "rain":0.15,
         "uvi":9.23
      },
      ...
   ],
    "alerts": [
    {
      "sender_name": "NWS Philadelphia - Mount Holly (New Jersey, Delaware, Southeastern Pennsylvania)",
      "event": "Small Craft Advisory",
      "start": 1684952747,
      "end": 1684988747,
      "description": "...SMALL CRAFT ADVISORY REMAINS IN EFFECT FROM 5 PM THIS\nAFTERNOON TO 3 AM EST FRIDAY...\n* WHAT...North winds 15 to 20 kt with gusts up to 25 kt and seas\n3 to 5 ft expected.\n* WHERE...Coastal waters from Little Egg Inlet to Great Egg\nInlet NJ out 20 nm, Coastal waters from Great Egg Inlet to\nCape May NJ out 20 nm and Coastal waters from Manasquan Inlet\nto Little Egg Inlet NJ out 20 nm.\n* WHEN...From 5 PM this afternoon to 3 AM EST Friday.\n* IMPACTS...Conditions will be hazardous to small craft.",
      "tags": [

      ]
    },
    ...
  ]
                
              

Fields in API response

If you do not see some of the parameters in your API response it means that these weather phenomena are just not happened for the time of measurement for the city or location chosen. Only really measured or calculated data is displayed in API response.
  • lat Latitude of the location, decimal (−90; 90)
  • lon Longitude of the location, decimal (-180; 180)
  • timezone Timezone name for the requested location
  • timezone_offset Shift in seconds from UTC
  • current Current weather data API response
    • current.dt Current time, Unix, UTC
    • current.sunrise Sunrise time, Unix, UTC. For polar areas in midnight sun and polar night periods this parameter is not returned in the response
    • current.sunset Sunset time, Unix, UTC. For polar areas in midnight sun and polar night periods this parameter is not returned in the response
    • current.temp Temperature. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
    • current.feels_like Temperature. This temperature parameter accounts for the human perception of weather. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit.
    • current.pressure Atmospheric pressure on the sea level, hPa
    • current.humidity Humidity, %
    • current.dew_point Atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit
    • current.clouds Cloudiness, %
    • current.uvi Current UV index.
    • current.visibility Average visibility, metres. The maximum value of the visibility is 10 km
    • current.wind_speed Wind speed. Wind speed. Units – default: metre/sec, metric: metre/sec, imperial: miles/hour. How to change units used
    • current.wind_gust (where available) Wind gust. Units – default: metre/sec, metric: metre/sec, imperial: miles/hour. How to change units used
    • current.wind_deg Wind direction, degrees (meteorological)
    • current.rain
      • current.rain.1h (where available) Precipitation, mm/h. Please note that only mm/h as units of measurement are available for this parameter
    • current.snow
      • current.snow.1h (where available) Precipitation, mm/h. Please note that only mm/h as units of measurement are available for this parameter
    • current.weather
  • minutely Minute forecast weather data API response
    • minutely.dt Time of the forecasted data, unix, UTC
    • minutely.precipitation Precipitation, mm/h. Please note that only mm/h as units of measurement are available for this parameter
  • hourly Hourly forecast weather data API response
    • hourly.dt Time of the forecasted data, Unix, UTC
    • hourly.temp Temperature. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
    • hourly.feels_like Temperature. This accounts for the human perception of weather. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit.
    • hourly.pressure Atmospheric pressure on the sea level, hPa
    • hourly.humidity Humidity, %
    • hourly.dew_point Atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit.
    • hourly.uvi UV index
    • hourly.clouds Cloudiness, %
    • hourly.visibility Average visibility, metres. The maximum value of the visibility is 10 km
    • hourly.wind_speed Wind speed. Units – default: metre/sec, metric: metre/sec, imperial: miles/hour.How to change units used
    • hourly.wind_gust (where available) Wind gust. Units – default: metre/sec, metric: metre/sec, imperial: miles/hour. How to change units used
    • hourly.wind_deg Wind direction, degrees (meteorological)
    • hourly.pop Probability of precipitation. The values of the parameter vary between 0 and 1, where 0 is equal to 0%, 1 is equal to 100%
    • hourly.rain
      • hourly.rain.1h (where available) Precipitation, mm/h. Please note that only mm/h as units of measurement are available for this parameter
    • hourly.snow
      • hourly.snow.1h (where available) Precipitation, mm/h. Please note that only mm/h as units of measurement are available for this parameter
    • hourly.weather
  • daily Daily forecast weather data API response
    • daily.dt Time of the forecasted data, Unix, UTC
    • daily.sunrise Sunrise time, Unix, UTC. For polar areas in midnight sun and polar night periods this parameter is not returned in the response
    • daily.sunset Sunset time, Unix, UTC. For polar areas in midnight sun and polar night periods this parameter is not returned in the response
    • daily.moonrise The time of when the moon rises for this day, Unix, UTC
    • daily.moonset The time of when the moon sets for this day, Unix, UTC
    • daily.moon_phase Moon phase. 0 and 1 are 'new moon', 0.25 is 'first quarter moon', 0.5 is 'full moon' and 0.75 is 'last quarter moon'. The periods in between are called 'waxing crescent', 'waxing gibbous', 'waning gibbous', and 'waning crescent', respectively. Moon phase calculation algorithm: if the moon phase values between the start of the day and the end of the day have a round value (0, 0.25, 0.5, 0.75, 1.0), then this round value is taken, otherwise the average of moon phases for the start of the day and the end of the day is taken
    • summaryHuman-readable description of the weather conditions for the day
    • daily.temp Units – default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
      • daily.temp.morn Morning temperature.
      • daily.temp.day Day temperature.
      • daily.temp.eve Evening temperature.
      • daily.temp.night Night temperature.
      • daily.temp.min Min daily temperature.
      • daily.temp.max Max daily temperature.
    • daily.feels_like This accounts for the human perception of weather. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
      • daily.feels_like.morn Morning temperature.
      • daily.feels_like.day Day temperature.
      • daily.feels_like.eve Evening temperature.
      • daily.feels_like.night Night temperature.
    • daily.pressure Atmospheric pressure on the sea level, hPa
    • daily.humidity Humidity, %
    • daily.dew_point Atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit.
    • daily.wind_speed Wind speed. Units – default: metre/sec, metric: metre/sec, imperial: miles/hour. How to change units used
    • daily.wind_gust (where available) Wind gust. Units – default: metre/sec, metric: metre/sec, imperial: miles/hour. How to change units used
    • daily.wind_deg Wind direction, degrees (meteorological)
    • daily.clouds Cloudiness, %
    • daily.uvi The maximum value of UV index for the day
    • daily.pop Probability of precipitation. The values of the parameter vary between 0 and 1, where 0 is equal to 0%, 1 is equal to 100%
    • daily.rain (where available) Precipitation volume, mm. Please note that only mm as units of measurement are available for this parameter
    • daily.snow (where available) Snow volume, mm. Please note that only mm as units of measurement are available for this parameter
    • daily.weather
  • alerts National weather alerts data from major national weather warning systems
    • alerts.sender_name Name of the alert source. Please read here the full list of alert sources
    • alerts.event Alert event name
    • alerts.start Date and time of the start of the alert, Unix, UTC
    • alerts.end Date and time of the end of the alert, Unix, UTC
    • alerts.description Description of the alert
    • alerts.tags Type of severe weather
National weather alerts are provided in English by default.
Please note that some agencies provide the alert’s description only in a local language.

Weather data for timestamp

To learn about how get access to weather data for any timestamp from 1st January 1979 till 4 days ahead forecast, please use this section of the documentation.

If you are interested in other functionality on One Call API 3.0, please check Product concept to follow the right section.

How to make an API call

API call

https://api.openweathermap.org/data/3.0/onecall/timemachine?lat={lat}&lon={lon}&dt={time}&appid={API key}
Parameters
lat required Latitude, decimal (-90; 90). If you need the geocoder to automatic convert city names and zip-codes to geo coordinates and the other way around, please use our Geocoding API
lon required Longitude, decimal (-180; 180). If you need the geocoder to automatic convert city names and zip-codes to geo coordinates and the other way around, please use our Geocoding API
dt required Timestamp (Unix time, UTC time zone), e.g. dt=1586468027. Data is available from January 1st, 1979 till 4 days ahead
appid required Your unique API key (you can always find it on your account page under the "API key" tab)
units optional Units of measurement. standardmetric and imperial units are available. If you do not use the units parameter, standard units will be applied by default. Learn more
lang optional You can use the lang parameter to get the output in your language. Learn more
Please note that the one API response contains weather data for only one specified timestamp.

Example of API call

Before making an API call, please note, that One Call 3.0 is included in the "One Call by Call" subscription only. Learn more

https://api.openweathermap.org/data/3.0/onecall/timemachine?lat=39.099724&lon=-94.578331&dt=1643803200&appid={API key}

Example of API response

Example of API response
                   
  {
  "lat": 52.2297,
  "lon": 21.0122,
  "timezone": "Europe/Warsaw",
  "timezone_offset": 3600,
  "data": [
    {
      "dt": 1645888976,
      "sunrise": 1645853361,
      "sunset": 1645891727,
      "temp": 279.13,
      "feels_like": 276.44,
      "pressure": 1029,
      "humidity": 64,
      "dew_point": 272.88,
      "uvi": 0.06,
      "clouds": 0,
      "visibility": 10000,
      "wind_speed": 3.6,
      "wind_deg": 340,
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ]
    }
  ]
}
                   
                 

Fields in API response

If you do not see some of the parameters in your API response it means that these weather phenomena are just not happened for the time of measurement for the city or location chosen. Only really measured or calculated data is displayed in API response.
  • lat Latitude of the location, decimal (−90; 90)
  • lon Longitude of the location, decimal (-180; 180)
  • timezone Timezone name for the requested location
  • timezone_offset Shift in seconds from UTC
  • data
    • data.dt Requested time, Unix, UTC
    • data.sunrise Sunrise time, Unix, UTC. For polar areas in midnight sun and polar night periods this parameter is not returned in the response
    • data.sunset Sunset time, Unix, UTC. For polar areas in midnight sun and polar night periods this parameter is not returned in the response
    • data.temp Temperature. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
    • data.feels_like Temperature. This accounts for the human perception of weather. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit.
    • data.pressure Atmospheric pressure on the sea level, hPa
    • data.humidity Humidity, %
    • data.dew_point Atmospheric temperature (varying according to pressure and humidity) below which water droplets begin to condense and dew can form. Units – default: kelvin, metric: Celsius, imperial: Fahrenheit.
    • data.clouds Cloudiness, %
    • data.uvi UV index. Please pay attention that historical UV index data available only for 5 days back. If you would like to get historical UVI index data starting from 20th September 2020 please contact us
    • data.visibility Average visibility, metres. The maximum value of the visibility is 10 km
    • data.wind_speed Wind speed. Units – default: metre/sec, metric: metre/sec, imperial: miles/hour. How to change units used
    • data.wind_gust (where available) Wind gust. Wind speed. Units – default: metre/sec, metric: metre/sec, imperial: miles/hour. How to change units used
    • data.wind_deg Wind direction, degrees (meteorological)
    • data.weather
    • data.rain (where available)
      • 1h Precipitation, mm/h. Please note that only mm/h as units of measurement are available for this parameter
    • data.snow(where available)
      • 1h Precipitation, mm/h. Please note that only mm/h as units of measurement are available for this parameter

Daily Aggregation

To learn about how get access to aggregated weather data for a particular date from 2nd January 1979 till long-term forecast for 1,5 years ahead, please use this section of the documentation.

If you are interested in other functionality on One Call API 3.0, please check Product concept to follow the right section.

How to make an API call

API call

https://api.openweathermap.org/data/3.0/onecall/day_summary?lat={lat}&lon={lon}&date={date}&appid={API key}
Parameters
lat required Latitude, decimal (-90; 90)
lon required Longitude, decimal (-180; 180)
date required Date in the `YYYY-MM-DD` format for which data is requested. Date is available for 45 years archive (starting from 1979-01-02) up to the 1,5 years ahead forecast to the current date
appid required Your unique API key (you can always find it on your account page under the "API key" tab)
units optional Units of measurement. standardmetric and imperial units are available. If you do not use the units parameter, standard units will be applied by default. Learn more
lang optional You can use the lang parameter to get the output in your language. Learn more
If the service detected timezone for your location incorrectly you can specify correct timezone manually by adding tz parameter in the ±XX:XX format to API call.

API call

https://api.openweathermap.org/data/3.0/onecall/day_summary?lat={lat}&lon={lon}&date={date}&tz={tz}&appid={API key}

Example of API call

https://api.openweathermap.org/data/3.0/onecall/day_summary?lat=60.45&lon=-38.67&date=2023-03-30&tz=+03:00&appid={API key} Please pay attention that in case timezone is specified time of afternoon, night, evening, morning temperatures, pressure, humidity will be returned in accordance with this specified timezone.

Example of API call

Before making an API call, please note, that One Call 3.0 is included in the "One Call by Call" subscription only. Learn more

https://api.openweathermap.org/data/3.0/onecall/day_summary?lat=39.099724&lon=-94.578331&date=2020-03-04&appid={API key}

Example of API response

Example of API response
                   
  {
   "lat":33,
   "lon":35,
   "tz":"+02:00",
   "date":"2020-03-04",
   "units":"standard",
   "cloud_cover":{
      "afternoon":0
   },
   "humidity":{
      "afternoon":33
   },
   "precipitation":{
      "total":0
   },
   "temperature":{
      "min":286.48,
      "max":299.24,
      "afternoon":296.15,
      "night":289.56,
      "evening":295.93,
      "morning":287.59
   },
   "pressure":{
      "afternoon":1015
   },
   "wind":{
      "max":{
         "speed":8.7,
         "direction":120
      }
   }
}                
                 

Fields in API response

  • lat Latitude of the location, decimal (−90; 90)
  • lon Longitude of the location, decimal (-180; 180)
  • tz Timezone in the ±XX:XX format
  • date Date specified in the API request in the `YYYY-MM-DD` format (from 1979-01-02 up to the 1,5 years ahead forecast)
  • units Units of measurement specified in the request. Learn more
  • cloud_cover Cloud related information
    • afternoon Cloud cover at 12:00 for the date specified in the request, %
  • humidity Humidity related information
    • afternoon Relative humidity at 12:00 for the date specified in the request, %
  • precipitation Precipitation related information
    • total Total amount of liquid water equivalent of precipitation for the date specified in the request, mm
  • pressure Atmospheric pressure related information
    • afternoon Atmospheric pressure at 12:00 for the date specified in the request, hPa
  • temperature Temperature related information
    • min Minimum temperature for the date specified in the request. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
    • max Maximum temperature for the date specified in the request. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
    • afternoon Temperature at 12:00 for the date specified in the request. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
    • night Temperature at 00:00 for the date specified in the request. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
    • evening Temperature at 18:00 for the date specified in the request. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
    • morning Temperature at 06:00 for the date specified in the request. Units - default: kelvin, metric: Celsius, imperial: Fahrenheit. How to change units used
  • wind Wind speed related information
    • max Maximum wind speed related information
      • speed Maximum wind speed for the date specified in the request. Units – default: metre/sec, metric: metre/sec, imperial: miles/hour. How to change units used
      • direction Wind cardinal direction relevant to the maximum wind speed, degrees (meteorological)

Weather overview

This section describes how to get weather overview with a human-readable weather summary for today and tomorrow's forecast, utilizing OpenWeather AI technologies.

If you are interested in other functionality on One Call API 3.0, please check Product concept to follow the right section.

How to make an API call

API call

https://api.openweathermap.org/data/3.0/onecall/overview?lat={lat}&lon={lon}&appid={API key}
Parameters
lat required Latitude, decimal (-90; 90)
lon required Longitude, decimal (-180; 180)
appid required Your unique API key (you can always find it on your account page under the "API key" tab)
date optional The date the user wants to get a weather summary in the YYYY-MM-DD format. Data is available for today and tomorrow. If not specified, the current date will be used by default. Please note that the date is determined by the timezone relevant to the coordinates specified in the API request
units optional Units of measurement. Standard, metric and imperial units are available. If you do not use the units parameter, standard units will be applied by default. Learn more

Example of API call

https://api.openweathermap.org/data/3.0/onecall/overview?lon=-11.8092&lat=51.509865&appid={API key} Example of API response
                   
{
   "lat": 51.509865,
   "lon": -0.118092,
   "tz": "+01:00",
   "date": "2024-05-13",
   "units": "metric",
   "weather_overview": "The current weather is overcast with a 
temperature of 16°C and a feels-like temperature of 16°C. 
The wind speed is 4 meter/sec with gusts up to 6 meter/sec 
coming from the west-southwest direction. 
The air pressure is at 1007 hPa with a humidity level of 79%. 
The dew point is at 12°C and the visibility is 10000 meters. 
The UV index is at 4, indicating moderate risk from the 
sun's UV rays. 
The sky is covered with overcast clouds, and there is 
no precipitation expected at the moment. 
Overall, it is a moderately cool and cloudy day 
with light to moderate winds from the west-southwest."
}          
                                       
                 

Fields in API response

  • lat Latitude of the location, decimal (−90; 90)
  • lon Longitude of the location, decimal (-180; 180)
  • tzTimezone in the ±XX:XX format
  • date Date for which summary is generated in the format YYYY-MM-DD
  • units Units of measurement specified in the request
  • weather_overviewAI generated weather overview for the requested date

Other features

List of weather condition codes

List of weather condition codes with icons (range of thunderstorm, drizzle, rain, snow, clouds, atmosphere etc.)

Units of measurement

standardmetric and imperial units are available.

List of all API parameters with available units.

API call

https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&units={units}
Parameters
units optional Units of measurement. standardmetric and imperial units are available. If you do not use the units parameter, standard units will be applied by default.
Temperature is available in Fahrenheit, Celsius and Kelvin units.

Wind speed is available in miles/hour and meter/sec.

  • For temperature in Fahrenheit and wind speed in miles/hour, use units=imperial
  • For temperature in Celsius and wind speed in meter/sec, use units=metric
  • Temperature in Kelvin and wind speed in meter/sec is used by default, so there is no need to use the units parameter in the API call if you want this

Examples of API calls

Standard (default)

api.openweathermap.org/data/3.0/onecall?lat=30.489772&lon=-99.771335

Metric

api.openweathermap.org/data/3.0/onecall?lat=30.489772&lon=-99.771335&units=metric

Imperial

api.openweathermap.org/data/3.0/onecall?lat=30.489772&lon=-99.771335&units=imperial

Multilingual support

You can use lang parameter to get the output in your language.

The contents of the description field will be translated.

API call

https://api.openweathermap.org/data/3.0/onecall?lat={lat}&lon={lon}&lang={lang}
Parameters
lang optional You can use the lang parameter to get the output in your language.

Example of API call

Before making an API call, please note, that One Call 3.0 is included in the "One Call by Call" subscription only. Learn more

https://api.openweathermap.org/data/3.0/onecall?lat=30.489772&lon=-99.771335&lang=zh_cn

We support the following languages. To select one, you can use the corresponding language code:

  • sq Albanian
  • af Afrikaans
  • ar Arabic
  • az Azerbaijani
  • eu Basque
  • be Belarusian
  • bg Bulgarian
  • ca Catalan
  • zh_cn Chinese Simplified
  • zh_tw Chinese Traditional
  • hr Croatian
  • cz Czech
  • da Danish
  • nl Dutch
  • en English
  • fi Finnish
  • fr French
  • gl Galician
  • de German
  • el Greek
  • he Hebrew
  • hi Hindi
  • hu Hungarian
  • is Icelandic
  • id Indonesian
  • it Italian
  • ja Japanese
  • kr Korean
  • ku Kurmanji (Kurdish)
  • la Latvian
  • lt Lithuanian
  • mk Macedonian
  • no Norwegian
  • fa Persian (Farsi)
  • pl Polish
  • pt Portuguese
  • pt_br Português Brasil
  • ro Romanian
  • ru Russian
  • sr Serbian
  • sk Slovak
  • sl Slovenian
  • sp, es Spanish
  • sv, se Swedish
  • th Thai
  • tr Turkish
  • ua, uk Ukrainian
  • vi Vietnamese
  • zu Zulu

List of national weather alerts sources

CountryAgency
Albania Institute of GeoSciences, Energy, Water and Environment of Albania
Algeria National Meteorological Office
Argentina National Weather Service of Argentina
Australia Australian Bureau of Meteorology
Austria
  • Central Institute for Meteorology and Geodynamics
  • Water Balance Department
Bahrain Bahrain Meteorological Directorate
Barbados Barbados Meteorological Service
Belarus State institution "Republican center for hydrometeorology, control of radioactive contamination and environmental monitoring" (Belhydromet)
Belgium Royal Meteorological Institute
Belize National Meteorological Service of Belize
Benin National Meteorological Agency (METEO-BENIN)
Bosnia and Herzegovina
  • Federal Hydrometeorological Institute of BiH
  • Republic Hydrometeorological Institute
Botswana Botswana Meteorological Services
Brazil National Meteorological Institute - INMET
Bulgaria National Institute of Meteorology and Hydrology - Plovdiv branch
Cameroon Cameroon National Meteorological Service
Canada
  • Alberta Emergency Management Agency (Government of Alberta, Ministry of Municipal Affairs)
  • Meteorological Service of Canada
  • Quebec Ministry of Public Safety
  • Yukon Emergency Measures Organization
  • Manitoba Emergency Management Organization
Chile Meteorological Directorate of Chile
Congo National Civil Aviation Agency (ANAC Congo)
Costa Rica National Meteorological Institute of Costa Rica
Croatia State Hydrometeorological Institute (DHMZ)
Curacao and Sint Maarten Meteorological Department Curacao
Cyprus Republic of Cyprus - Department of Meteorology
Czech Republic Czech Hydrometeorological Institute
Denmark Danish Meteorological Institute
Ecuador Ecuadoran Institute for Meteorology and Hydrology (INAMHI)
Egypt Egyptian Meteorological Authority
Estonia Estonian Environment Agency
Eswatini Eswatini Meteorological Service
Finland Finnish Meteorological Institute
France Meteo-France
Gabon General Directorate of Meteorology of Gabon
Germany German Meteorological Office
Ghana Ghana Meteorological Agency
Greece Hellenic National Meteorological Service
Guinea National Meteorological Agency of Guinea
Guyana Hydrometeorological Service of Guyana
Hong Kong China Hong Kong Observatory
Hungary Hungarian Meteorological Service
Iceland Icelandic Meteorological Office
India India Meteorological Department
Indonesia
  • Agency for Meteorology Climatology and Geophysics of Republic Indonesia (BMKG)
  • InaTEWS BMKG
Ireland Met Eireann - Irish Meteorological Service
Israel Israel Meteorological Service
Italy Italian Air Force National Meteorological Service
Ivory Coast Airport, aeronautical and meteorological operating and development company (SODEXAM)
Jamaica Meteorological Service of Jamaica
Jordan Jordanian Meteorological Department
Kazakhstan National Hydrometeorological Service of the Republic of Kazakhstan (Kazhydromet)
Kenya Kenya Meteorological Department
Kuwait Kuwait Meteorological Department
Latvia Latvian Environment, Geology and Meteorology Center
Lesotho Lesotho Meteorological Services
Libya Libyan National Meteorological Center
Lithuania Lithuanian Hydrometeorological Service under the Ministry of Environment of the Republic of Lithuania (LHMS)
Luxembourg Luxembourg Airport Administration
Macao China Macao Meteorological and Geophysical Bureau
Madagascar METEO Madagascar
Malawi Malawi Department of Climate Change and Meteorological Services
Maldives Maldives Meteorological Service
Mauritania National Meteorological Office of Mauritania
Mauritius Mauritius Meteorological Services
Mexico CONAGUA - National Meteorological Service of Mexico
Moldova State Hydrometeorological Service of Moldova
Mongolia National Agency Meteorology and the Environmental Monitoring of Mongolia
Mozambique National Institute of Meteorology of Mozambique
Myanmar Myanmar Department of Meteorology and Hydrology
Netherlands Royal Netherlands Meteorological Institute (KNMI)
New Zealand
  • Meteorological Service of New Zealand Limited
  • National Emergency Management Agency
  • Fire and Emergency New Zealand
  • Civil Defence Emergency Management (CDEM) Groups
New Zealand New Zealand Emergency Mobile Alert
Niger National Meteorological Directorate of Niger
Nigeria Nigerian Meteorological Agency (NiMet)
North Macedonia National Hydrometeorological Service - Republic of Macedonia
Norway
  • Norwegian Meteorological Institute
  • Norwegian Water Resources and Energy Directorate
Paraguay Directorate of Meteorology and Hydrology
Philippines Philippine Atmospheric Geophysical and Astronomical Services Administration
Poland Institute of Meteorology and Water Management (IMGW-PIB)
Portugal Portuguese Institute of Sea and Atmosphere, I.P.
Qatar Qatar Meteorology Department
Republic of Korea Korea Meteorological Administration, Weather Information
Romania National Meteorological Administration
Russia-EN Hydrometcenter of Russia
Russia-RU Russian Federal Service for Hydrometeorology and Environmental Monitoring
Saudi Arabia National Center for Meteorology - Kingdom of Saudi Arabia
Serbia Republic Hydrometeorological Service of Serbia
Seychelles Seychelles Meteorological Authority
Singapore Meteorological Service Singapore
Slovakia Slovak Hydrometeorological Institute
Slovenia National Meteorological Service of Slovenia
Solomon Islands Solomon Islands Meteorological Services
South Africa South African Weather Service (SAWS)
Spain State Meteorological Agency (AEMET)
Sudan Sudan Meteorological Authority
Sweden Swedish Meteorological and Hydrological Institute
Switzerland MeteoSwiss
Tanzania Tanzania Meteorological Authority
Thailand Thai Meteorological Department
Timor-Leste National Directorate of Meteorology and Geophysics of Timor-Leste
Trinidad and Tobago Trinidad and Tobago Meteorological Service
Ukraine Ukrainian Hydrometeorological Center
United Kingdom of Great Britain and Northern Ireland UK Met Office
Uruguay Uruguayan Institute of Meteorology
United States
  • Environmental Protection Agency (EPA), Air Quality Alerts
  • Integrated Public Alerrt and Warning System (IPAWS)
  • National Oceanic and Atmospheric Administration (NOAA), National Tsunami Warning Center
  • National Oceanic and Atmospheric Administration (NOAA), National Weather Service
  • National Oceanic and Atmospheric Administration (NOAA), National Weather Service - Marine Zones
  • U.S. Geological Survey (USGS), Volcano Hazard Program
USA National Oceanic and Atmospheric Administration
Yemen Yemeni Civil Aviation and Meteorology Authority (CAMA)
Zambia Meteorological Department Zambia
Zimbabwe Meteorological Services Department

Please note that some agencies from the list may cease to provide us the weather alert information.
In case you don’t receive alerts from any agency, please contact us.
We constantly work on our product’s improvement and keep expanding the list of partner agencies.

Call back function for JavaScript code

To use JavaScript code you can transfer callback functionName to JSONP callback.

API call example

api.openweathermap.org/data/3.0/onecall?lat=38.8&lon=12.09&callback=test

API errors

Structure of API errors

In case of incorrected API call you will receive API error response. Error response payload returned for all types of errors with the structure below.

Example of error response

Example of error response
                
{
    "cod":400,
    "message":"Invalid date format",
    "parameters": [
        "date"
    ]
}
        
              

Fields in error response

  • cod Code of error
  • message Description of error
  • parameters(optional) List of request parameters names that are related to this particular error

Errors list


Please find more detailed information about some popular errors below.

API calls return an error 400

API calls return an error 401

API calls return an error 404

API calls return an error 429

API calls return errors '5xx'

Product Collections

Subscription

Company

OpenWeather is a team of IT experts and data scientists that has been practising deep weather data science. For each point on the globe, OpenWeather provides historical, current and forecasted weather data via light-speed APIs. Headquarters in London, UK.

Technologies

Terms & Conditions

下载 OpenWeather 应用程序

从 AppStore 获取 从 Google Play 获取 RMets 徽标 Achilles UVDB 社区供应商
© 2012 — 2024 OpenWeather ® 保留所有权利

脸书图标x 图标领英图标图标电报图标github 图标    

标签:API,Meteorological,daily,weather,call,units,data,Example
From: https://www.cnblogs.com/flyingsir/p/18433582

相关文章

  • 解决 nvm error cb() never called! 问题
    在获取到一个项目使用npminstall安装依赖时,可能会遇到该问题网上有很多方法说是清理缓存进行处理#安装快速删除工具npminstall-grimraf#删除目录(请在项目根目录下执行删除命令,以免误删除)rimrafnode_modules#清空缓存npmcacheclean--force#验证缓存npmc......
  • DISM API(Deployment Image Servicing and Management API)是一个用于服务和管理 Window
    DISMAPI参考|MicrosoftLearn基本DISMAPI示例|MicrosoftLearn部署映像服务和管理(DISM)API|MicrosoftLearnDISMAPI(DeploymentImageServicingandManagementAPI)是一个用于服务和管理Windows映像文件的接口,特别用于处理Windows操作系统的安装、维护和更......
  • 抖音开放平台API接口如何开发抖音相关接口数据采集数据分析 【附实例】
    抖音开放平台提供了多种接口,包括授权登录、用户信息、视频管理、评论互动、消息通知、数据分析等。以下是开发抖音接口的一些步骤:注册开发者账号:在抖音开放平台上注册开发者账号,获取开发者身份认证。创建应用:登录开放平台后,创建自己的应用,获取应用的AppID和AppSecret。授权登录:......
  • 1688商品详情API在跨境电子商务中的重要性
    一、引言随着全球电子商务的迅速发展和普及,跨境电子商务已经成为国际贸易的一种重要形式。1688作为全球最大的B2B电子商务平台之一,不仅为国内商家提供了丰富的商品资源,同时也为跨境商家提供了广阔的商品信息和交易机会。为了更好地满足跨境商家的需求,1688推出了商品详情API接口,这......
  • 《消逝的光芒2》游戏无法正常启动:提示steam_api.dll错误的解决方法
    针对《消逝的光芒2》游戏无法正常启动并提示steam_api.dll错误的问题,可以尝试以下几种解决方法:一、验证游戏文件完整性打开Steam客户端:确保已经登录Steam账户。访问游戏库:在Steam主界面上方找到“库”选项,点击进入。选择游戏:在游戏库中找到《消逝的光芒2》,右键点击该游戏图......
  • 基于SqlAlchemy+Pydantic+FastApi的Python开发框架的路由处理
    在前面随笔《基于SqlAlchemy+Pydantic+FastApi的Python开发框架 》中介绍了框架总体的内容,其中主要的理念就是通过抽象接口的方式,实现代码的重用,提高开发效率。本篇随笔深入介绍一下FastApi的路由处理部分的内容,通过基类继承的方式,我们可以简化路由器(或者叫WebAPI控制器)的基础......
  • PHP车牌识别API接口示例-车牌识别接口助力智慧出行
    在智能化、数字化迅速发展的今天,交通管理作为城市运作的核心环节之一,也正经历着前所未有的变革。无论是在停车场管理、道路监控,还是智慧城市建设中,传统的人工交通管理方式早已无法满足现代社会对高效、安全的出行需求。于是,车牌识别接口应运而生,以其卓越的智能化处理能力,为智......
  • PHP视频活体检测API接口示例-视频活体检测引领身份验证新潮流
    在数字化时代,身份验证几乎是每个行业的核心环节之一。从金融支付到电子商务,从社交网络到政府服务,确保用户身份的真实有效变得至关重要。然而,传统的用户名与密码验证方式已经难以应对日益复杂的安全威胁,特别是在黑客攻击、账户盗用、虚假身份愈加猖獗的今天,安全需求不断提升。......
  • 微信支付开发-支付工厂AppApi查账代码
    一、JSAPI支付产品、APP支付产品、小程序支付产品流程图二、工厂父类抽象类代码开发<?php/***微信父类抽象类*User:龙哥·三年风水*Date:2024/9/19*Time:11:33*/namespacePayment\WechatPay;abstractclassWechatPaymentHandle{/***下单......
  • 获取淘宝商品详情:API接口
    淘宝商品详情API接口概述淘宝商品详情API接口是淘宝开放平台提供的一项服务,允许开发者通过商品ID获取商品的详细信息。这些信息对于商家来说,可以帮助他们更好地管理商品信息,优化库存,提升用户体验。如何使用淘宝商品详情API使用淘宝商品详情API通常包括以下步骤:注册淘宝开放平......