Skip to main content

akvo-weather-info

A Python library to fetch weather data from multiple providers (OpenWeatherMap, WeatherAPI.com, Google Weather).

Installation

pip install akvo-weather-info

For development:

pip install -e .

Configuration

Create a .env file in your project root with API keys:

OPENWEATHER=your_openweathermap_api_key
WEATHERAPI=your_weatherapi_api_key
GOOGLEWEATHER=your_google_maps_api_key

Get API keys from:

Library Usage

Basic Import

from weather.services import OpenWeatherMapService, WeatherAPIService, GoogleWeatherService

# Using OpenWeatherMap
owm = OpenWeatherMapService()
current = owm.get_current("Jakarta")
print(f"Temperature: {current.temperature}C")
print(f"Condition: {current.description}")

# Using WeatherAPI.com
wa = WeatherAPIService()
current = wa.get_current("London")
print(f"Temperature: {current.temperature}C")

# Using Google Weather
gw = GoogleWeatherService()
current = gw.get_current("Tokyo")
print(f"Temperature: {current.temperature}C")

Query by Coordinates

All services support coordinate-based queries:

from weather.services import OpenWeatherMapService, GoogleWeatherService

# OpenWeatherMap by coordinates
owm = OpenWeatherMapService()
current = owm.get_current_by_coords(lat=-6.2088, lon=106.8456)
hourly = owm.get_forecast_hourly_by_coords(lat=-6.2088, lon=106.8456, hours=24)

# Google Weather by coordinates (skips geocoding)
gw = GoogleWeatherService()
current = gw.get_current_by_coords(lat=51.5074, lon=-0.1278)
daily = gw.get_forecast_daily_by_coords(lat=51.5074, lon=-0.1278, days=7)

Get Forecast

from weather.services import OpenWeatherMapService

service = OpenWeatherMapService()

# Hourly forecast
hourly = service.get_forecast_hourly("Tokyo", hours=24)
for forecast in hourly:
    print(f"{forecast.forecast_time}: {forecast.temperature}C")

# Daily forecast
daily = service.get_forecast_daily("New York", days=5)
for forecast in daily:
    print(f"{forecast.forecast_time.date()}: {forecast.temperature}C")

Get Raw API Response

from weather.services import WeatherAPIService

service = WeatherAPIService()

# Raw response as dict
raw = service.get_current_raw("Jakarta")
print(raw["current"]["temp_c"])
print(raw["current"]["condition"]["text"])

# Raw forecast
raw_forecast = service.get_forecast_raw("Jakarta")
print(raw_forecast["forecast"]["forecastday"])

Data Models

from weather.models import WeatherData, Forecast

# WeatherData fields
weather.location      # str: "Jakarta, ID"
weather.temperature   # float: temperature in Celsius
weather.feels_like    # float: feels like temperature
weather.humidity      # int: humidity percentage
weather.description   # str: weather description
weather.wind_speed    # float: wind speed in m/s
weather.timestamp     # datetime: data timestamp

# Convert to dict
data_dict = weather.to_dict()

Formatters

from weather.services import OpenWeatherMapService
from weather.formatters import format_json, format_text

service = OpenWeatherMapService()
current = service.get_current("Jakarta")

# Format as JSON string
json_output = format_json(current)

# Format as readable text
text_output = format_text(current)

CLI Usage

# By location name
python -m weather --service=<SERVICE> --location=<LOCATION> [--output=<FORMAT>] [--forecast=<TYPE>] [--raw]

# By coordinates
python -m weather --service=<SERVICE> --lat=<LAT> --lon=<LON> [--output=<FORMAT>] [--forecast=<TYPE>] [--raw]

Arguments

Argument Required Values Description
--service Yes owm, wa, gw Weather service (owm = OpenWeatherMap, wa = WeatherAPI.com, gw = Google Weather)
--location * string Location name (e.g., "Jakarta", "London,UK")
--lat * float Latitude (use with --lon)
--lon * float Longitude (use with --lat)
--output No text, json Output format (default: text)
--forecast No hour, day Forecast type. If omitted, shows current weather
--raw No flag Show raw API response without field mapping

* Either --location OR both --lat and --lon are required.

CLI Examples

# Current weather by location
python -m weather --service=owm --location="Jakarta"

# Current weather by coordinates
python -m weather --service=gw --lat=-6.2088 --lon=106.8456

# JSON output
python -m weather --service=wa --location="London" --output=json

# Hourly forecast
python -m weather --service=gw --location="Tokyo" --forecast=hour

# Daily forecast by coordinates
python -m weather --service=owm --lat=40.7128 --lon=-74.0060 --forecast=day

# Raw API response
python -m weather --service=owm --location="Jakarta" --raw --output=json

Project Structure

weather/
├── __init__.py
├── __main__.py          # CLI entry point
├── cli.py               # Argument parsing
├── config.py            # API key management
├── models.py            # Data models (WeatherData, Forecast)
├── services/
│   ├── base.py          # Abstract base class
│   ├── openweathermap.py
│   ├── weatherapi.py
│   └── google_weather.py
└── formatters/
    ├── json_formatter.py
    ├── text_formatter.py
    └── raw_formatter.py

Requirements

  • Python >= 3.10
  • httpx
  • python-dotenv

Release files for akvo-weather-info 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for akvo-weather-info 0.3.0
File Size Uploaded
akvo_weather_info-0.3.0.tar.gz 23.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for akvo-weather-info 0.3.0
File Interpreter ABI Platform
akvo_weather_info-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 51.3 kB

Release files / akvo_weather_info-0.3.0.tar.gz

Download URL akvo_weather_info-0.3.0.tar.gz
Size 23.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c8f52a16157db667b937786e3bcf0e2b5cf66c10d3996be023be43f804a2cc53
BLAKE2b-256 checksum
How to use checksums
f26bd4e7664e58e524323f558dc1b9afb9539d0b78495fcf4765d3df92fd12c4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 24, 2026.

Transparency log

Release files / akvo_weather_info-0.3.0-py3-none-any.whl

Download URL akvo_weather_info-0.3.0-py3-none-any.whl
Size 28.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abda89c9fd6147d111d2145ece40da6548079d061787965d30f50e49e6266733
BLAKE2b-256 checksum
How to use checksums
7cead5907d033e4fa9ac06520cb16f9dc17568ff39c2d0e011c3eaf285035642
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page