https://openweathermap.org/current
Current weather data
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
Please remember that all Examples of API calls that listed on this page are just samples and do not have any connection to the real API service!
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.
There is a possibility to receive a central district of the city/town with its own parameters (geographic coordinates/id/name) in API response. Example
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:
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 IDExamples of API calls:
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 interestExamples of API calls:
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
Description:
Please note if country is not specified then the search works for USA as a default.
API call:
api.openweathermap.org/data/2.5/weather?zip={zip code},{country code}Examples of API calls:
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 [lon-left,lat-bottom,lon-right,lat-top,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,10Cities 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. The default number of cities is 10, the maximum is 50.
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:
Call for several city IDs
Parameters:
id City IDExamples of API calls:
The limit of locations is 20.
NOTE: A single ID counts as a one API call! So, the above example is treated as a 3 API calls.
NOTE: A single ID counts as a one API call! So, the above example is treated as a 3 API calls.
Bulk downloading
Description:
We provide number of bulk files with current weather and forecasts. More information is on the Bulk page
Bulk downloading is available not for all accounts. To get more information please refer to theprice.
Examples of bulk files:
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, longitudecoord.lat
City geo location, latitude
weather
(more info Weather condition codes)weather.id
Weather condition idweather.main
Group of weather parameters (Rain, Snow, Extreme etc.)weather.description
Weather condition within the groupweather.icon
Weather icon id
base
Internal parametermain
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), hPamain.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, hPamain.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, UTCsys
sys.type
Internal parametersys.id
Internal parametersys.message
Internal parametersys.country
Country code (GB, JP etc.)sys.sunrise
Sunrise time, unix, UTCsys.sunset
Sunset time, unix, UTC
id
City IDname
City namecod
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 IDcity.name
City namecity.coord
city.coord.lon
City geo location, longitudecity.coord.lat
City geo location, latitude
city.country
Country code (GB, JP etc.)city.sun
city.sun.rise
Sunrise timecity.sun.set
Sunset time
temperature
temperature.value
Temperaturetemperature.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 valuehumidity.unit
%
pressure
pressure.value
Pressure valuepressure.unit
hPa
wind
wind.speed
wind.speed.value
Wind speed, mpswind.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
Cloudinessclouds.name
Name of the cloudiness
visibility
visibility.value
Visibility, meter
precipitation
precipitation.value
Precipitation, mmprecipitation.mode
Possible values are 'no", name of weather phenomena as 'rain', 'snow'
weather
weather.number
Weather condition idweather.value
Weather condition nameweather.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:
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:
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:
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:
Arabic - ar, Bulgarian - bg, Catalan - ca, Czech - cz, German - de, Greek - el, English - en, Persian (Farsi) - fa, Finnish - fi, French - fr, Galician - gl, Croatian - hr, Hungarian - hu, Italian - it, Japanese - ja, Korean - kr, Latvian - la, Lithuanian - lt, Macedonian - mk, Dutch - nl, Polish - pl, Portuguese - pt, Romanian - ro, Russian - ru, Swedish - se, Slovak - sk, Slovenian - sl, Spanish - es, Turkish - tr, Ukrainian - ua, Vietnamese - vi, Chinese Simplified - zh_cn, Chinese Traditional - zh_tw.
Arabic - ar, Bulgarian - bg, Catalan - ca, Czech - cz, German - de, Greek - el, English - en, Persian (Farsi) - fa, Finnish - fi, French - fr, Galician - gl, Croatian - hr, Hungarian - hu, Italian - it, Japanese - ja, Korean - kr, Latvian - la, Lithuanian - lt, Macedonian - mk, Dutch - nl, Polish - pl, Portuguese - pt, Romanian - ro, Russian - ru, Swedish - se, Slovak - sk, Slovenian - sl, Spanish - es, Turkish - tr, Ukrainian - ua, Vietnamese - vi, Chinese Simplified - zh_cn, Chinese Traditional - zh_tw.
NOTE: Translation is only applied for the "description" field.
API call:
http://api.openweathermap.org/data/2.5/forecast/daily?id=524901&lang={lang}Parameters:
lang language codeExamples of API calls:
http://api.openweathermap.org/data/2.5/forecast/daily?id=524901&lang=zh_cnCall back function for JavaScript code
Description:
To use JavaScript code you can transfer callback functionName to JSONP callback.
0 comments:
Post a Comment