Skip to main content

Adiyogi Weather SDK (Python)

PyPI version License: MIT Python

A comprehensive Python SDK for accessing high-precision weather, climate, and environmental data with async/await support and full type hints.

📦 Installation

pip install adiyogi-weather

🚀 Quick Start

from adiyogi_weather import Adiyogi
import asyncio

async def main():
    async with Adiyogi() as client:
        # Get current weather
        weather = await client.weather.get_current(
            lat=40.7128,
            lon=-74.0060
        )
        
        print(f"Temperature: {weather.temperature}°C")
        print(f"Condition: {weather.condition}")

if __name__ == "__main__":
    asyncio.run(main())

🌟 Features

  • ✅ Fully Typed - Complete type hints with Pydantic models
  • ✅ Async/Await - Built on asyncio and httpx
  • ✅ Type Safe - Pydantic validation for all responses
  • ✅ Zero Config - Works out of the box
  • ✅ Error Handling - Comprehensive exception types
  • ✅ Python 3.8+ - Modern Python support

📚 Services

Weather Forecast

async with Adiyogi() as client:
    # Get 7-day forecast
    forecast = await client.weather.get_forecast(
        lat=52.52,
        lon=13.41,
        days=7
    )
    
    for day in forecast.daily:
        print(f"{day.date}: {day.temperature.max}°C")

Historical Data

from datetime import datetime, timedelta

async with Adiyogi() as client:
    # Get historical weather
    end_date = datetime.now()
    start_date = end_date - timedelta(days=7)
    
    historical = await client.historical.get_range(
        lat=52.52,
        lon=13.41,
        start_date=start_date,
        end_date=end_date
    )
    
    print(f"Average temp: {historical.avg_temperature}°C")

Air Quality

async with Adiyogi() as client:
    # Get current air quality
    air_quality = await client.air_quality.get_current(
        lat=28.61,
        lon=77.20
    )
    
    print(f"AQI: {air_quality.aqi}")
    print(f"PM2.5: {air_quality.pm25}")

Marine Data

async with Adiyogi() as client:
    # Get marine forecast
    marine = await client.marine.get_forecast(
        lat=35.6762,
        lon=139.6503,
        days=3
    )
    
    print(f"Wave height: {marine.wave_height}m")

Elevation

async with Adiyogi() as client:
    # Get elevation
    elevation = await client.elevation.get_elevation(
        lat=47.5162,
        lon=14.5501
    )
    
    print(f"Elevation: {elevation.altitude}m")

Geocoding

async with Adiyogi() as client:
    # Search for locations
    results = await client.geocoding.search(query="London")
    
    for location in results:
        print(f"{location.name}, {location.country}")

🔧 Advanced Configuration

from adiyogi_weather import Adiyogi, AdiyogiConfig

config = AdiyogiConfig(
    api_key="your-api-key",
    base_url="https://api.adiyogi.com",
    timeout=10.0,
    max_retries=3,
    cache_enabled=True
)

async with Adiyogi(config=config) as client:
    weather = await client.weather.get_current(lat=40.7, lon=-74)

📖 API Reference

Client Methods

  • client.weather.get_current(lat, lon) - Current weather
  • client.weather.get_forecast(lat, lon, days) - Weather forecast
  • client.historical.get_range(lat, lon, start_date, end_date) - Historical data
  • client.air_quality.get_current(lat, lon) - Air quality
  • client.marine.get_forecast(lat, lon, days) - Marine forecast
  • client.elevation.get_elevation(lat, lon) - Elevation data
  • client.geocoding.search(query) - Location search
  • client.climate.get_projections(lat, lon) - Climate projections
  • client.solar.get_radiation(lat, lon) - Solar radiation

Pydantic Models

from adiyogi_weather.models import (
    WeatherResponse,
    ForecastResponse,
    HistoricalResponse,
    AirQualityResponse
)

# All responses are validated Pydantic models
weather: WeatherResponse = await client.weather.get_current(lat=40.7, lon=-74)

⚠️ Error Handling

from adiyogi_weather.exceptions import (
    NetworkError,
    ValidationError,
    APIError
)

try:
    async with Adiyogi() as client:
        weather = await client.weather.get_current(lat=40.7, lon=-74)
except NetworkError as e:
    print(f"Network issue: {e}")
except ValidationError as e:
    print(f"Invalid parameters: {e}")
except APIError as e:
    print(f"API error: {e}")

🔄 Synchronous Usage

For non-async environments:

from adiyogi_weather import AdiyogiSync

client = AdiyogiSync()
weather = client.weather.get_current(lat=40.7128, lon=-74.0060)
print(f"Temperature: {weather.temperature}°C")

🧪 Testing

# Run tests
pytest

# Run with coverage
pytest --cov=adiyogi_weather

📝 Type Checking

# Run mypy
mypy adiyogi_weather

📄 License

MIT License - see LICENSE for details

🤝 Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details.

📞 Support

For support, email support@adiyogi.com or open an issue on GitHub.

🌍 Examples

Weather Dashboard

import asyncio
from adiyogi_weather import Adiyogi

async def weather_dashboard(cities):
    async with Adiyogi() as client:
        tasks = [
            client.weather.get_current(lat=lat, lon=lon)
            for lat, lon in cities
        ]
        results = await asyncio.gather(*tasks)
        
        for city, weather in zip(cities, results):
            print(f"{city}: {weather.temperature}°C - {weather.condition}")

cities = [(40.7128, -74.0060), (51.5074, -0.1278), (35.6762, 139.6503)]
asyncio.run(weather_dashboard(cities))

Historical Analysis

from adiyogi_weather import Adiyogi
from datetime import datetime, timedelta
import pandas as pd

async def analyze_temperature_trend():
    async with Adiyogi() as client:
        end_date = datetime.now()
        start_date = end_date - timedelta(days=365)
        
        data = await client.historical.get_range(
            lat=40.7128,
            lon=-74.0060,
            start_date=start_date,
            end_date=end_date
        )
        
        # Convert to pandas DataFrame
        df = pd.DataFrame(data.daily)
        print(f"Average temperature: {df['temperature'].mean():.1f}°C")
        print(f"Max temperature: {df['temperature'].max():.1f}°C")
        print(f"Min temperature: {df['temperature'].min():.1f}°C")

asyncio.run(analyze_temperature_trend())

Metadata

Release files for adiyogi-weather 1.0.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 adiyogi-weather 1.0.0
File Size Uploaded Provenance Actions
adiyogi_weather-1.0.0.tar.gz 17.1 kB Without provenance Details for adiyogi_weather-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for adiyogi-weather 1.0.0
File Interpreter ABI Platform Actions
adiyogi_weather-1.0.0-py3-none-any.whl Python 3 none any Details for adiyogi_weather-1.0.0-py3-none-any.whl

Total release size: 42.7 kB

Release files / adiyogi_weather-1.0.0.tar.gz

Download URL adiyogi_weather-1.0.0.tar.gz
Size 17.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f14b8b88a4c7296e61c990d1962ea03ac9592e13d18559f57befe28ca7afc9f5
BLAKE2b-256 checksum
How to use checksums
54666e1ab284c3c57dac7390aac99beaeb9b56f616dfc459f2c4183d6b213e55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Release files / adiyogi_weather-1.0.0-py3-none-any.whl

Download URL adiyogi_weather-1.0.0-py3-none-any.whl
Size 25.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99d0cd946136fc8def9a8cb7282d74ced4e9176c90e123d56c8d67048288d527
BLAKE2b-256 checksum
How to use checksums
d4309f777917494312eb183a44ebb710b181a09f97d616de8b57b2172f5d66b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.2

Security for adiyogi-weather 1.0.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

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