[Open API] OpenweatherMap Open API

OpenweatherMap

날씨 정보를 제공하는 OpenAPI로 APi key를 발급받아 사용한다.

https://www.openweathermap.org/

Usage

OpenWeatherMap은 API 호출시 API Key를 APPID 파라미터로 전달한다. 예를 들어 서울의 날씨를 얻으려면

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

그러나 한 API Key로 10분에 1번 호출 해야 한다.

API Key

4ecbcfa0c4210bfff11d93ea02cd9290

1
http://api.openweathermap.org/data/2.5/weather?q=seoul,kr&appid=4ecbcfa0c4210bfff11d93ea02cd9290

API 가입

https://openweathermap.org/api 에서 원하는 API를 골라 Subscribe 한 후에 사용할 수 있다. 가입 자격에 따라서 API 호출 빈도가 달라진다.

Weather data

JSON
Example of API respond:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{
"coord": {
"lon": 126.98,
"lat": 37.57
},
"weather": [
{
"id": 701,
"main": "Mist",
"description": "mist",
"icon": "50n"
}
],
"base": "stations",
"main": {
"temp": 276.15,
"pressure": 1013,
"humidity": 64,
"temp_min": 276.15,
"temp_max": 276.15
},
"visibility": 11265,
"wind": {
"speed": 5.7,
"deg": 310
},
"clouds": {
"all": 90
},
"dt": 1523044560,
"sys": {
"type": 1,
"id": 7673,
"message": 0.0075,
"country": "KR",
"sunrise": 1522962579,
"sunset": 1523008779
},
"id": 1835848,
"name": "Seoul",
"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
Author

Gangtai Goh

Posted on

2018-06-15

Updated on

2023-01-19

Licensed under

댓글