API/2.1/JSON API

From OpenWeatherMap
(Redirected from API/JSON API)
Jump to: navigation, search

Contents

Getting Data from JSON version 2.1

All data can be obtained in JSON format. The following interfaces for data obtaining have already developed and available for everybody:

  • Weather Stations with last data
  • Cities with the current weather data
  • History of measurement for each weather station

When using data from this web-site please comply the conditions of the CC-BY-SA license


What`s new?


Previous versions of API

( plz dont use it )


Find current weather

This API group let you receive actual data from weather stations and currect weather in cities all over the world. You can choose different searching ways:

  • Choose a rectangle shaped area boarded by geographic coordiates. As a result you get list of weather stations existed within the chosen area.
  • Choose coordinates of a geo point and receive list of the nearest weather stations.
  • Choose a geo point and max distance to it. As a result you get all geo points that lay within the chosen max distance.



Find around point

Example

Choose a geo point and max weather station quantity. As a result you get a list of weather stations that lay arount the geo point.

The same is for the list of current weather in cities


Parametrs

To find weather stations

Parametr Description
lat latitude
lon longitude
cnt Limit the number of points in the selection
callback functionName for JSONP calback. http://en.wikipedia.org/wiki/JSONP
cluster Use server clustering of points. Possible values ​​are [yes, no]
lang Language [ru, en, de, fr, es, it] if is posible

Result

Weather

{"message":"type=cityModel:GFS-OWM, zoom=5","cod":"200","calctime":0.0141,"cnt":42,"list":[

{"id":88319,"dt":1345284000,"name":"Benghazi",
    "coord":{"lat":32.12,"lon":20.07},
    "main":{"temp":306.15,"pressure":1013,"humidity":44,"temp_min":306,"temp_max":306},
    "wind":{"speed":1,"deg":-7},
    "weather":[{"id":800,"main":"Clear","description":"sky is clear"}],
    "clouds":{"all":0},
    "rain":{"3h":0}},
,...

Stations

{"message":"type=station, fetch=0.0495, allcnt=842","cod":"200","calctime":0.6788,"cnt":682,"list":[

{"id":5995,"dt":1345280400,"rang":50,"cluster":2,"name":"Sibiu","type":1,
    "coord":{"lat":45.7858,"lon":24.0856},
    "main":{"temp":297.15,"pressure":1021,"humidity":44},
    "wind":{"speed":3.1,"deg":360}},
....

More about data API/2.0/Station_Data



Bounding Box find

JSON query returns the data from cities or weather stations that have meteorological information and whose geographic coordinates lay within the rectangle BBOX

Example

Parametrs

To find stations

Parametr Description
bbox Bounding Box
callback javascript functionName
cluster Use server clustering of points. Possible values ​​are [yes, no]
lang Language [ru, en ... ]


Result

Like a center find More about data


Bounding radius find

JSON query returns the data from cities or weather stations that have meteorological information and whose geographic coordinates lay within circle. A circle is specified by a center point and radius:

Example

Parametrs

To find stations

Parametr Description
lat latitude
lon longitude
radius radius in kilometers
callback functionName for JSONP calback.
cluster Use server clustering of points. Possible values ​​are [yes, no]
lang Language [ru, en ... ]


Find City via name

Find city via its name. The inquiry retunes list of cities that match search substring.

Find city like mode

With country code

units (imperial, metric, internal)


Get current weather by city id

You can get current weather in concrete chosen city. For that you need to know city ID. You can get data as JSON or HTML code.

api.openweathermap.org/data/2.1/weather/city/{CITY_ID}?type={json|html}

example

Units (Fahrenheit, Celsius )

You can use Imperial units like http://api.openweathermap.org/data/2.1/weather/city/7169710?units=imperial

And Metric http://api.openweathermap.org/data/2.1/weather/city/7169710?units=metric


Get forecast

Get forecast by city id

Weather forecast in the city for the next 7 days.

http://api.openweathermap.org/data/2.1/forecast/city/{CITY_ID}

http://api.openweathermap.org/data/2.1/forecast/city/524901

{"message":"","cod":"200","calctime":0.0189,"list":[
{"dt":1345251600,
    "main":{"temp":286.6,"humidity":98,"pressure":1002,"temp_min":286,"temp_max":287},
    "wind":{"speed":0,"deg":-2},
    "rain":{"3h":2},
    "clouds":{"all":56},
    "weather":{"id":803,"main":"Clouds","description":"broken clouds", "img":"..." }
....


Get forecast by city Name

Weather forecast in the city for the next 7 days.

http://api.openweathermap.org/data/2.1/forecast/city?q=Moscow

Daily forecast

http://api.openweathermap.org/data/2.2/forecast/city/5128581?mode=daily_compact 

Weather Stations information

Last measures made by weather station with ID = STATION_ID You can get data as JSON or HTML code.

api.openweathermap.org/data/2.1/weather/station/{STATION_ID}?type={json|html}

example


Stations and City history

Set of requests let you get weather station measured data.

City History

Parametr Description
type [tick, hour, day ]
start Data start (unix time)
end Data end (unix time)


history tick

List of several measurements made by weather station.

{"message":"","cod":"200","type":"tick","station_id":39419,"cnt":30,
"list":[
{"dt":1345291920,
    "main":{"temp":291.55,"humidity":95,"pressure":1009.3},
    "wind":{"speed":0,"gust":0.3},
    "rain":{"1h":0.6,"today":2.7},
    "calc":{"dewpoint":17.6} }
...

API/2.0/Station_Data

history hours

Measurements grouped by hours.

{"message":"","cod":"200","type":"hour","station_id":39419, "cnt":27, "list":[

{"dt":1345190400,
   "rain":{
       "1h":{"v":0,"c":6,"mi":0,"ma":0},
       "today":{"v":0.9,"c":6,"mi":0.9,"ma":0.9}},
   "calc":{
       "dewpoint":{"v":16.35,"c":6,"mi":16.1,"ma":16.8}},
   "wind":{
       "speed":{"v":0,"c":6,"mi":0,"ma":0},
       "gust":{"v":0.62,"c":6,"mi":0.3,"ma":1.4}},
   "main":{
       "humidity":{"v":71.67,"c":6,"mi":68,"ma":74},
       "temp":{"v":294.87,"c":6,"mi":294.15,"ma":295.45},
       "pressure":{"v":1009.97,"c":6,"mi":1009.9,"ma":1010}}},
.....


history days

Measurements grouped by days.


Restrictions

Please treat with understanding to the limited capabilities of our servers. If you send more than 2,000 requests per hour we can limit the speed of response to your requests or even refuse to service them. Anyway if you need a large volume of data please registered and get APPID. Its FREE!

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox