Sync-only Python SDK for OpenWeatherMap (base pattern)
Project description
Sync OpenWeatherAPI Python SDK 🌦️
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.
📚 Table of Contents
- 🚀 Features
- 🧩 Installation
- 🔑 Setup
- 🧠 Usage
- 🧪 Testing
- 🏗️ Project structure
- 🧰 Development shortcuts
- 🪶 License
- 🌍 Roadmap
🚀 Features
- 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)
🧩 Installation
From source (recommended for development)
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]'
🔑 Setup
Create a .env file in the project root:
OPENWEATHER_KEY=your_real_api_key_here
Never commit your
.env— it’s already ignored in.gitignore.
🧠 Usage
Basic example
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']}")
With .env auto-load
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']))
🧪 Testing
Run all tests offline:
pytest -q
Check lint & types:
ruff check .
mypy openweather
🏗️ Project structure
sync_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
🧰 Development shortcuts
| Command | Purpose |
|---|---|
pytest -q |
run tests |
ruff check . |
lint code |
mypy openweather |
type-check |
python -m examples.usage_sync |
manual run |
🪶 License
MIT License © 2025 [Nitin S. Kulkarni]
🌍 Roadmap
- Async client (
httpx) - One Call API
- CLI entrypoint (
ow current --city Pune) - GitHub Actions CI pipeline
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 sync_openweatherapi_python_sdk-0.1.2.tar.gz.
File metadata
- Download URL: sync_openweatherapi_python_sdk-0.1.2.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f821a330ea7f5cf403ec87dcb36b33f8726f33280759b7f81b83766c3c26b695
|
|
| MD5 |
278391713f7473aa28bac9f85832151b
|
|
| BLAKE2b-256 |
9fdc503d141bcae744e1fb882f0ee13950724830245954f02480570093f3e469
|
File details
Details for the file sync_openweatherapi_python_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: sync_openweatherapi_python_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a364b9767237ef61a3b342b345eda370632d5328e4a0d8aeffaa153f89770cb
|
|
| MD5 |
74530b22adedac1e72ce34b4931ab3a5
|
|
| BLAKE2b-256 |
77d12e0da7246b1356451d9a8e42e5439ca0da4ca7a3853d1992d32b238b3dea
|