본문 바로가기
Chapter01/Open API

[ OpenWeatherMap API ] 위치 기반 날씨 정보 제공 글로벌 API

by EmmaDev_v 2025. 2. 11.
반응형

 

접속한 위치 기반으로

현재 날씨 정보를 가져옴

 

 

 

 

위 화면 중

서울특별시 부분을 제외한 

날씨 받아오는 부분 !! 을 구현하는데에 사용한  API임

 

 

 

 

공식 문서

https://openweathermap.org/api?utm_source=chatgpt.com

 

Weather API - OpenWeatherMap

Ulla OpenWeather AI assistant Chat with Ulla Ask her anything about OpenWeather products

openweathermap.org

 

 

 

 

회원가입 하기 

 

 

 

 

나는 현재 날씨만 궁금하므로

무료인 Current Weather Data를 구독함.

 

 

 

 

 

 

Billing Plans에서 볼 수 있는

결제한 내역.. (0원 이지만)

 

 

 

 

 

 

 

API Keys 탭을 클릭하면

Key가 발급되어있음

 

 

 

 

 

 

 

 

발급 받은 키로 API 요청 날려봄

 

 

 

받은 response

{
    "coord": {
        "lon": 127.0255,
        "lat": 37.5679
    },
    "weather": [
        {
            "id": 800,
            "main": "Clear",
            "description": "맑음",
            "icon": "01d"
        }
    ],
    "base": "stations",
    "main": {
        "temp": 2.92,
        "feels_like": 2.92,
        "temp_min": -1.18,
        "temp_max": 2.92,
        "pressure": 1032,
        "humidity": 60,
        "sea_level": 1032,
        "grnd_level": 1019
    },
    "visibility": 10000,
    "wind": {
        "speed": 1.21,
        "deg": 95,
        "gust": 1.62
    },
    "clouds": {
        "all": 1
    },
    "dt": 1739240231,
    "sys": {
        "type": 1,
        "id": 8105,
        "country": "KR",
        "sunrise": 1739226378,
        "sunset": 1739264767
    },
    "timezone": 32400,
    "id": 6800746,
    "name": "Kwanghŭi-dong",
    "cod": 200
}

 

 

입력한 위도 경도의 날씨를 가지고오는데

웹 페이지에서 현재 위치 사용 권한에 동의하면

거기서 수집한 정보를 이용함.

 

 

그리고

"main"의 "temp" 를 기온 , "humidity"를 습도

"wind"의 "speed" 가 풍속

으로 표시함

 

"name" 이 지역명인데

이건 정확하지 않아서

위도, 경도 가지고 지역명 구하는건 다른 API를 사용했다

 

https://dev-emma-dev.tistory.com/254

 

[ OpenStreetMap nominatim API ] 위도 경도로 지역명 가져오기

쩐에 썻던 OpenWeatherMap API는 위도 경도를 가지고 날씨 정보를 가지고옴고객사는 여기에 지역명도 표시해주실 원했당   OpenWeatherMap API 도 지역명을 구할 수 있으나, 정확하지 않음 서울특별시

dev-emma-dev.tistory.com

 

 

 

 

 

"icon"의 값으로

사용할 수 있는 아이콘 목록 

 

 

https://openweathermap.org/weather-conditions

 

Weather Conditions - OpenWeatherMap

Ulla OpenWeather AI assistant Chat with Ulla Ask her anything about OpenWeather products

openweathermap.org

 

반응형