스터디/Processing 2016. 4. 14. 22:48

Openweather API


1. openweathermap API에서 현재 날씨 불러오기


도시 이름으로 불러오기

도시 ID로 불러오기

위치값으로 불러오기
http://api.openweathermap.org/data/2.5/weather?lat=36.321388&lon=127.419724

우편주소로 불러오기
http://api.openweathermap.org/data/2.5/weather?zip=305701,kr

디폴트 모드는 javascript를 위한 JSON이므로 주소 뒤에 xml로 불러오는 부분 추가
&mode=xml

화씨를 섭씨로 바꾸는 부분
&units=metric


대전 현재 날씨


+ 160428  추가
 APIkey 를 별도로 신청해서 기입해야하는 방식으로 바뀜
http://openweathermap.org/appid#get
가입후 무료 API key 신청 후 할당받은 키를 코드 맨 뒤에  &APPID=12345838 이런 식으로 추가해주면 됨 

2. 날씨 예보

오늘 예보 : weather부분을 forecast/daily 로 교체

5일 예보 : weather부분을 forecast 로 교체

3. 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.sun.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.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


4. 주요 도시

Daegu
1835329




Seoul
1835848

Daejeon
1835235