Tool

Fetch weather data from OpenWeatherMap into LlamaIndex

Load current and forecast weather data for named cities into LlamaIndex documents.

Works with openweathermapllamaindex

74
Spark score
out of 100
Updated 2 days ago
Version 0.14.23

Add to Favorites

Why it matters

Load current weather conditions, hourly forecasts, and daily forecasts from OpenWeatherMap's OneCall API for specified cities into LlamaIndex documents for downstream AI processing and retrieval.

Outcomes

What it gets done

01

Connect to OpenWeatherMap OneCall API using authentication token

02

Retrieve current weather data for specified city locations

03

Fetch 48-hour hourly and 7-day daily weather forecasts

04

Transform weather data into LlamaIndex document format

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/li-reader-readers-weather | bash

Overview

Weather Loader

A LlamaIndex reader that loads current and forecast weather data for named cities via OpenWeatherMap's OneCall API. Use for current, 48-hour, and 7-day forecast data on specific cities, including country codes for accuracy.

What it does

The Weather Loader fetches weather data from OpenWeatherMap's OneCall API, using the pyowm Python package, and loads it as LlamaIndex documents. The loader is initialized with an OpenWeatherMap API token, and load_data takes an array of city names to fetch weather for.

OWM's OneCall API, which this loader wraps, provides current weather, an hourly forecast covering the next 48 hours, and a daily forecast covering the next 7 days for any geographical coordinate. Passing country codes alongside city names (for example "Chennai, IN" rather than just "Chennai") is recommended for better location accuracy.

When to use - and when NOT to

Use it when you need current conditions plus short-term (48-hour) and medium-term (7-day) forecast data for one or more named cities loaded into LlamaIndex as documents. Include country codes with city names to avoid ambiguous location matches. Do not use it for locations beyond what OpenWeatherMap's OneCall API covers, or for forecast ranges beyond 7 days - the underlying API doesn't provide data further out.

Capabilities

load_data fetches current weather plus 48-hour hourly and 7-day daily forecasts for a list of named cities (optionally with country codes) via OpenWeatherMap's OneCall API.

How to install

from llama_index.readers.weather import WeatherReader

loader = WeatherReader(token="[YOUR_TOKEN]")
documents = loader.load_data(places=["Chennai, IN", "Dublin, IE"])

Requires an OpenWeatherMap API token.

Who it's for

Developers who need current and forecast weather data for a list of specific cities loaded into LlamaIndex, for retrieval or question-answering about conditions in those places.

Source README

Weather Loader

pip install llama-index-readers-weather

This loader fetches the weather data from the OpenWeatherMap's OneCall API, using the pyowm Python package. You must initialize the loader with your OpenWeatherMap API token, and then pass in the names of the cities you want the weather data for.

OWM's One Call API provides the following weather data for any geographical coordinate: - Current weather - Hourly forecast for 48 hours - Daily forecast for 7 days

Usage

To use this loader, you need to pass in an array of city names (eg. [chennai, chicago]). Pass in the country codes as well for better accuracy.

from llama_index.readers.weather import WeatherReader

loader = WeatherReader(token="[YOUR_TOKEN]")
documents = loader.load_data(places=["Chennai, IN", "Dublin, IE"])

This loader is designed to be used as a way to load data into LlamaIndex.

FAQ

Common questions

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.