OpenWeatherMap Current weather data

http://openweathermap.org/current

Access current weather data for any location on Earth including over 200,000 cities! Current weather is frequently updated based on global models and data from more than 40,000 weather stations. Data is available in JSON, XML, or HTML format.

Call current weather data for one location

By city name

Description:
You can call by city name or city name and country code. API responds with a list of results that match a searching word.
API call:

api.openweathermap.org/data/2.5/weather?q={city name}

api.openweathermap.org/data/2.5/weather?q={city name},{country code}

Parameters:

q city name and country code divided by comma, use ISO 3166 country codes

Examples of API calls:

api.openweathermap.org/data/2.5/weather?q=London

api.openweathermap.org/data/2.5/weather?q=London,uk

By city ID

Description:

You can call by city ID. API responds with exact result.

List of city ID city.list.json.gz can be downloaded here http://bulk.openweathermap.org/sample/

We recommend to call API by city ID to get unambiguous result for your city.

Parameters:
id City ID
Examples of API calls:

api.openweathermap.org/data/2.5/weather?id=2172797

By geographic coordinates

API call:
api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}
Parameters:
lat, lon coordinates of the location of your interest
Examples of API calls:

api.openweathermap.org/data/2.5/weather?lat=35&lon=139

API respond:
{"coord":{"lon":139,"lat":35},
"sys":{"country":"JP","sunrise":1369769524,"sunset":1369821049},
"weather":[{"id":804,"main":"clouds","description":"overcast clouds","icon":"04n"}],
"main":{"temp":289.5,"humidity":89,"pressure":1013,"temp_min":287.04,"temp_max":292.04},
"wind":{"speed":7.31,"deg":187.002},
"rain":{"3h":0},
"clouds":{"all":92},
"dt":1369824698,
"id":1851632,
"name":"Shuzenji",
"cod":200}

By ZIP code

API call:
api.openweathermap.org/data/2.5/weather?zip={zip code},{country code}
Examples of API calls:

api.openweathermap.org/data/2.5/weather?zip=94040,us

Parameters:

zip zip code

API respond:
{"coord":{"lon":-122.09,"lat":37.39},
"sys":{"type":3,"id":168940,"message":0.0297,"country":"US","sunrise":1427723751,"sunset":1427768967},
"weather":[{"id":800,"main":"Clear","description":"Sky is Clear","icon":"01n"}],
"base":"stations",
"main":{"temp":285.68,"humidity":74,"pressure":1016.8,"temp_min":284.82,"temp_max":286.48},
"wind":{"speed":0.96,"deg":285.001},
"clouds":{"all":0},
"dt":1427700245,
"id":0,
"name":"Mountain View",
"cod":200}

Call current weather data for several cities

Cities within a rectangle zone

Description:

JSON returns the data from cities within the defined rectangle specified by the geographic coordinates.

Parameters:

bbox bounding box [lat of the top left point, lon of the top left point, lat of the bottom right point, lon of the bottom right point, map zoom]

callback javascript functionName

cluster use server clustering of points. Possible values ​​are [yes, no]

lang language [ru, en ... ]

Examples of API calls:
http://api.openweathermap.org/data/2.5/box/city?bbox=12,32,15,37,10&cluster=yes

Cities in cycle

Description:

JSON returns data from cities laid within definite circle that is specified by center point ('lat', 'lon') and expected number of cities ('cnt') around this point.

Parameters:

lat latitude

lon longitude

callback functionName for JSONP callback.

cluster use server clustering of points. Possible values ​​are [yes, no]

lang language [en , ru ... ]

cnt number of cities around the point that should be returned

Examples of API calls:

http://api.openweathermap.org/data/2.5/find?lat=55.5&lon=37.5&cnt=10

Call for several city IDs

Parameters:
id City ID
Examples of API calls:

http://api.openweathermap.org/data/2.5/group?id=524901,703448,2643743&units=metric


Bulk downloading

Description:

As a standard we provide bulk of current weather for 20,000 cities, updated hourly. File name is weather_14.json.gz.

You can find this file in the list of bulk examples.

Other files in the list are examples of forecast. Please, read about them on the Forecast page.

Bulk downloading is available for not the all accounts. To get more information please refer to the price.

Examples of bulk files:

http://bulk.openweathermap.org/sample/


Weather parameters in API respond

If you do not see some of the parameters in your API respond 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 respond.

JSON

Example of API respond:
{"coord":
{"lon":145.77,"lat":-16.92},
"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],
"base":"cmc stations",
"main":{"temp":293.25,"pressure":1019,"humidity":83,"temp_min":289.82,"temp_max":295.37},
"wind":{"speed":5.1,"deg":150},
"clouds":{"all":75},
"rain":{"3h":3},
"dt":1435658272,
"sys":{"type":1,"id":8166,"message":0.0166,"country":"AU","sunrise":1435610796,"sunset":1435650870},
"id":2172797,
"name":"Cairns",
"cod":200}

Parameters:
  • coord
    • coord.lon City geo location, longitude
    • coord.lat City geo location, latitude
  • weather (more info Weather condition codes)
    • weather.id Weather condition id
    • weather.main Group of weather parameters (Rain, Snow, Extreme etc.)
    • weather.description Weather condition within the group
    • weather.icon Weather icon id
  • base Internal parameter
  • main
    • main.temp Temperature. Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
    • main.pressure Atmospheric pressure (on the sea level, if there is no sea_level or grnd_level data), hPa
    • main.humidity Humidity, %
    • main.temp_min Minimum temperature at the moment. This is deviation from current temp that is possible for large cities and megalopolises geographically expanded (use these parameter optionally). Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
    • main.temp_max Maximum temperature at the moment. This is deviation from current temp that is possible for large cities and megalopolises geographically expanded (use these parameter optionally). Unit Default: Kelvin, Metric: Celsius, Imperial: Fahrenheit.
    • main.sea_level Atmospheric pressure on the sea level, hPa
    • main.grnd_level Atmospheric pressure on the ground level, hPa
  • wind
    • wind.speed Wind speed. Unit Default: meter/sec, Metric: meter/sec, Imperial: miles/hour.
    • wind.deg Wind direction, degrees (meteorological)
  • clouds
    • clouds.all Cloudiness, %
  • rain
    • rain.3h Rain volume for the last 3 hours
  • snow
    • snow.3h Snow volume for the last 3 hours
  • dt Time of data calculation, unix, UTC
  • sys
    • sys.type Internal parameter
    • sys.id Internal parameter
    • sys.message Internal parameter
    • sys.country Country code (GB, JP etc.)
    • sys.sunrise Sunrise time, unix, UTC
    • sys.sunset Sunset time, unix, UTC
  • id City ID
  • name City name
  • cod Internal parameter

XML

Example of API respond:
<current>
<city id="2643741" name="City of London">
 <coord lon="-0.09" lat="51.51"/>
 <country>GB</country>
 <sun rise="2015-06-30T03:46:57" set="2015-06-30T20:21:12"/>
</city>
<temperature value="72.34" min="66.2" max="79.88" unit="fahrenheit"/>
<humidity value="43" unit="%"/>
<pressure value="1020" unit="hPa"/>
<wind>
 <speed value="7.78" name="Moderate breeze"/>
 <direction value="140" code="SE" name="SouthEast"/>
</wind>
<clouds value="0" name="clear sky"/>
<visibility value="10000"/>
<precipitation mode="no"/>
<weather number="800" value="Sky is Clear" icon="01d"/>
<lastupdate value="2015-06-30T08:36:14"/>
</current>

Parameters:
  • city
    • city.id City ID
    • city.name City name
    • city.coord
      • city.coord.lon City geo location, longitude
      • city.coord.lat City geo location, latitude
    • city.country Country code (GB, JP etc.)
    • city.sun
      • city.sun.rise Sunrise time
      • city.coord.set Sunset time
  • temperature
    • temperature.value Temperature
    • temperature.min Minimum temperature at the moment of calculation. This is deviation from 'temp' that is possible for large cities and megalopolises geographically expanded (use these parameter optionally).
    • temperature.max Maximum temperature at the moment of calculation. This is deviation from 'temp' that is possible for large cities and megalopolises geographically expanded (use these parameter optionally).
    • temperature.unit Unit of measurements. Possilbe valure is Celsius, Kelvin, Fahrenheit.
  • humidity
    • humidity.value Humidity value
    • humidity.unit %
  • pressure
    • pressure.value Pressure value
    • pressure.unit hPa
  • wind
    • wind.speed
      • wind.speed.value Wind speed, mps
      • wind.speed.name Type of the wind
    • wind.direction
      • wind.direction.value Wind direction, degrees (meteorological)
      • wind.direction.code Code of the wind direction. Possilbe value is WSW, N, S etc.
      • wind.direction.name Full name of the wind direction.
  • clouds
    • clouds.value Cloudiness
    • clouds.name Name of the cloudiness
  • visibility
    • visibility.value Visibility, meter
  • precipitation
    • precipitation.value Precipitation, mm
    • precipitation.mode Possible values are 'no", name of weather phenomena as 'rain', 'snow'
  • weather
    • weather.number Weather condition id
    • weather.value Weather condition name
    • weather.icon Weather icon id
  • lastupdate
    • lastupdate.value Last time when data was updated

List of weather condition codes

List of weather condition codes with icons (range of thunderstorm, drizzle, rain, snow, clouds, atmosphere including extreme conditions like tornado, hurricane etc.)


Min/max temperature in current weather API and forecast API

Please, do not confuse min/max parameters in current weather API and forecast API. In current weather API temp_min and temp_max are optional parameters mean min / max temperature in the city at the current moment to see deviation from current temp just for your reference. For large cities and megalopolises geographically expanded it might be applicable. In most cases both temp_min and temp_max parameters have the same volume as 'temp'. Please, use temp_min and temp_max parameters in current weather API optionally.

Example of current weather API respond:
"main":{
"temp":306.15, //current temperature 
"pressure":1013,
"humidity":44,
"temp_min":306, //min current temperature in the city
"temp_max":306 //max current temperature in the city
},
For comparison look at example of daily forecast weather API respond:
"dt":1406080800,
"temp":{
        "day":297.77,  //daily averaged temperature
        "min":293.52, //daily min temperature
        "max":297.77, //daily max temperature
        "night":293.52, //night temperature
        "eve":297.77, //evening temperature
        "morn":297.77}, //morning temperature

Other features

Format

Description:

JSON format is used by default. To get data in XML or HTML formats just set up mode = xml or html.

Parameters:
mode - possible values are xml and html. If mode parameter is empty the format is JSON by default.
Examples of API calls:

JSON api.openweathermap.org/data/2.5/weather?q=London

XML api.openweathermap.org/data/2.5/weather?q=London&mode=xml

HTML api.openweathermap.org/data/2.5/weather?q=London&mode=html

Search accuracy

Description:

You can use our geocoding system to find cities by name, country, zip-code or geographic coordinates. You can call also by part of the city name. To make the result more accurate just put the city name and country divided by comma.

To set the accuracy level either use the 'accurate' or 'like' type parameter. 'accurate' returns exact match values. 'like' returns results by searching for that substring. 

Call API by city ID instead of city name, city coordinates or zip code. In this case you get precise respond exactly for your city.
Parameters:

like close result

accurate accurate result

Examples of API calls:

Like api.openweathermap.org/data/2.5/find?q=London&type=like&mode=xml

Accurate api.openweathermap.org/data/2.5/find?q=London&type=accurate&mode=xml

Units format

Description:

Standard, metric, and imperial units are available.

Parameters:

units metric, imperial. When you do not use units parameter, format is Standard by default.

Temperature is available in Fahrenheit, Celsius and Kelvin units.

  • For temperature in Fahrenheit use units=imperial
  • For temperature in Celsius use units=metric
  • Temperature in Kelvin is used by default, no need to use units parameter in API call

List of all API parameters with units openweathermap.org/weather-data

Examples of API calls:

standard api.openweathermap.org/data/2.5/find?q=London

metric api.openweathermap.org/data/2.5/find?q=London&units=metric

imperial api.openweathermap.org/data/2.5/find?q=London&units=imperial

Multilingual support

Description:

You can use lang parameter to get the output in your language. We support the following languages that you can use with the corresponded lang values: English - en, Russian - ru, Italian - it, Spanish - es (or sp), Ukrainian - uk (or ua), German - de, Portuguese - pt, Romanian - ro, Polish - pl, Finnish - fi, Dutch - nl, French - fr, Bulgarian - bg, Swedish - sv (or se), Chinese Traditional - zh_tw, Chinese Simplified - zh (or zh_cn), Turkish - tr, Croatian - hr, Catalan - ca 

API call:
http://api.openweathermap.org/data/2.5/forecast/daily?id=524901&lang={lang}
Parameters:
lang language code
Examples of API calls:
http://api.openweathermap.org/data/2.5/forecast/daily?id=524901&lang=zh_cn

Call back function for JavaScript code

Description:

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

Examples of API calls:
api.openweathermap.org/data/2.5/weather?q=London,uk&callback=test

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值