A comprehensive Python SDK for Adiyogi Weather API - High-precision weather, climate, and environmental data
Project description
Adiyogi Weather SDK (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 weatherclient.weather.get_forecast(lat, lon, days)- Weather forecastclient.historical.get_range(lat, lon, start_date, end_date)- Historical dataclient.air_quality.get_current(lat, lon)- Air qualityclient.marine.get_forecast(lat, lon, days)- Marine forecastclient.elevation.get_elevation(lat, lon)- Elevation dataclient.geocoding.search(query)- Location searchclient.climate.get_projections(lat, lon)- Climate projectionsclient.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.
🔗 Links
📞 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())
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adiyogi_weather-1.0.0.tar.gz.
File metadata
- Download URL: adiyogi_weather-1.0.0.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f14b8b88a4c7296e61c990d1962ea03ac9592e13d18559f57befe28ca7afc9f5
|
|
| MD5 |
74be29ebe9aec13790960469cd052472
|
|
| BLAKE2b-256 |
54666e1ab284c3c57dac7390aac99beaeb9b56f616dfc459f2c4183d6b213e55
|
File details
Details for the file adiyogi_weather-1.0.0-py3-none-any.whl.
File metadata
- Download URL: adiyogi_weather-1.0.0-py3-none-any.whl
- Upload date:
- Size: 25.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
99d0cd946136fc8def9a8cb7282d74ced4e9176c90e123d56c8d67048288d527
|
|
| MD5 |
0b3118dd68f687754ec9d0e3dcd1974b
|
|
| BLAKE2b-256 |
d4309f777917494312eb183a44ebb710b181a09f97d616de8b57b2172f5d66b0
|