A lightweight, synchronous Python SDK for OpenWeatherMap API.
Provides clean abstractions for common endpoints like Current Weather and 5-Day Forecast, built with developer ergonomics and testability in mind.
- 🚀 Features
- 🧩 Installation
- 🔑 Setup
- 🧠 Usage
- 🧪 Testing
- 🏗️ Project structure
- 🧰 Development shortcuts
- 🪶 License
- 🌍 Roadmap
- Sync client using
requestswith connection pooling and retries - Built-in error handling (
AuthenticationError,RateLimitError, etc.) - Optional Pydantic models for typed responses
.envsupport viapython-dotenv- 100 % offline test suite with
pytest+responses - Type-checked (
mypy) & linted (ruff)
git clone https://github.com/nkpythondeveloper/sync_openweatherapi_python_sdk.git
cd sync_openweatherapi_python_sdk
python -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'Create a .env file in the project root:
OPENWEATHER_KEY=your_real_api_key_hereNever commit your
.env— it’s already ignored in.gitignore.
from openweather import OpenWeatherClient
client = OpenWeatherClient(api_key="YOUR_KEY")
data = client.get_current_weather(city="Pune")
print(f"{data['name']}: {data['main']['temp']}°C, {data['weather'][0]['description']}")import os
from dotenv import load_dotenv
from openweather import OpenWeatherClient
load_dotenv()
client = OpenWeatherClient(api_key=os.getenv("OPENWEATHER_KEY"))
forecast = client.get_forecast(city="Pune")
print(forecast['city']['name'], len(forecast['list']))Run all tests offline:
pytest -qCheck lint & types:
ruff check .
mypy openweathersync_openweatherapi_python_sdk/
├── openweather/
│ ├── __init__.py
│ ├── client.py
│ ├── endpoints.py
│ ├── exceptions.py
│ ├── models.py
│ └── utils.py
├── examples/
│ └── usage_sync.py
├── tests/
│ └── test_client_sync.py
├── pyproject.toml
└── README.md
| Command | Purpose |
|---|---|
pytest -q |
run tests |
ruff check . |
lint code |
mypy openweather |
type-check |
python -m examples.usage_sync |
manual run |
MIT License © 2025 [Nitin S. Kulkarni]
- Async client (
httpx) - One Call API
- CLI entrypoint (
ow current --city Pune) - GitHub Actions CI pipeline