OpenWeatherMap은 특정 위치에 대한 모든 필수 날씨 데이터를 제공합니다:
  • 현재 날씨
  • 1시간 분 단위 예보
  • 48시간 시간별 예보
  • 8일 일별 예보
  • 국가 기상 경보
  • 40년 이상의 과거 날씨 데이터
이 페이지에서는 LangChain 내에서 OpenWeatherMap API를 사용하는 방법을 다룹니다.

Installation and Setup

  • 다음 명령어로 필요한 패키지를 설치하세요:
pip install pyowm
  • OpenWeatherMap에 접속하여 계정을 등록하고 여기에서 API key를 받으세요
  • API key를 OPENWEATHERMAP_API_KEY environment variable로 설정하세요

Wrappers

Utility

이 API를 래핑하는 OpenWeatherMapAPIWrapper utility가 존재합니다. 이 utility를 import하려면:
from langchain_community.utilities.openweathermap import OpenWeatherMapAPIWrapper
이 wrapper에 대한 자세한 안내는 이 notebook을 참조하세요.

Tool

이 wrapper를 Tool로 쉽게 로드할 수도 있습니다 (Agent와 함께 사용). 다음과 같이 할 수 있습니다:
import os
from langchain_community.utilities import OpenWeatherMapAPIWrapper

os.environ["OPENWEATHERMAP_API_KEY"] = ""
weather = OpenWeatherMapAPIWrapper()
tools = [weather.run]
tool에 대한 자세한 정보는 이 페이지를 참조하세요.
Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I