Skip to main content

Webservice-OpenWeatherMap

Sääpalvelu openWeatherMap:

Palvelusta saa luettua nykyisen säätilan, tai ennusteita ympäri maailman.

Dokumentaatio:
https://openweathermap.org/current
https://openweathermap.org/forecast5

NYKYINEN SÄÄTILA

URL:
    http://api.openweathermap.org/data/2.5/weather

Parametrit:

    ?q={city name}
    ?q={city name},{country code}
    ?id={cityIdCode}
    ?lat=35&lon=139
    ?mode={dataMode} dataMode = "json" | "xml"

Vastaus:

    "main":{
        "temp":306.15,
        "pressure":1013,
        "humidity":44,
        "temp_min":306,
        "temp_max":306
    }


ENNUSTE 5 VRK

Antaa ennusteen haluttuun paikkaan 3 tunnin välein, max 5 vuorokaudeksi.

Vastauksessa jokainen rivi edustaa 3 tunnin jaksoa.

URL:
    http://api.openweathermap.org/data/2.5/forecast

Parametrit:

    ?q={city name}
    ?q={city name},{country code}
    ?id={cityIdCode}
    ?lat=35&lon=139
    ?mode={json|xml}
    ?cnt={nRows}
    ?units={metric|imperial}

Esimerkiksi:
    http://api.openweathermap.org/data/2.5/forecast?q=tampere,fi&units=metric

Vastaus (rajoitettu 4 vastaus riviin):

{
  "cod": "200",
  "message": 0.0032,
  "cnt": 4,
  "list": [
    {
      "dt": 1487246400,
      "main": {
        "temp": 286.67,
        "temp_min": 281.556,
        "temp_max": 286.67,
        "pressure": 972.73,
        "sea_level": 1046.46,
        "grnd_level": 972.73,
        "humidity": 75,
        "temp_kf": 5.11
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.81,
        "deg": 247.501
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-02-16 12:00:00"
    },
    {
      "dt": 1487257200,
      "main": {
        "temp": 285.66,
        "temp_min": 281.821,
        "temp_max": 285.66,
        "pressure": 970.91,
        "sea_level": 1044.32,
        "grnd_level": 970.91,
        "humidity": 70,
        "temp_kf": 3.84
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.59,
        "deg": 290.501
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-02-16 15:00:00"
    },
    {
      "dt": 1487268000,
      "main": {
        "temp": 277.05,
        "temp_min": 274.498,
        "temp_max": 277.05,
        "pressure": 970.44,
        "sea_level": 1044.7,
        "grnd_level": 970.44,
        "humidity": 90,
        "temp_kf": 2.56
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.41,
        "deg": 263.5
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-02-16 18:00:00"
    },
    {
      "dt": 1487624400,
      "main": {
        "temp": 272.424,
        "temp_min": 272.424,
        "temp_max": 272.424,
        "pressure": 968.38,
        "sea_level": 1043.17,
        "grnd_level": 968.38,
        "humidity": 85,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02n"
        }
      ],
      "clouds": {
        "all": 20
      },
      "wind": {
        "speed": 3.57,
        "deg": 255.503
      },
      "rain": {},
      "snow": {},
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-02-20 21:00:00"
    }
  ],
  "city": {
    "id": 6940463,
    "name": "Altstadt",
    "coord": {
      "lat": 48.137,
      "lon": 11.5752
    },
    "country": "none"
  }
}