Skip to main content

Sync-only Python SDK for OpenWeatherMap (base pattern)

Project description

PyPI version License

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

  • Sync client using requests with connection pooling and retries
  • Built-in error handling (AuthenticationError, RateLimitError, etc.)
  • Optional Pydantic models for typed responses
  • .env support via python-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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sync_openweatherapi_python_sdk-0.1.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file sync_openweatherapi_python_sdk-0.1.2.tar.gz.

File metadata

File hashes

Hashes for sync_openweatherapi_python_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f821a330ea7f5cf403ec87dcb36b33f8726f33280759b7f81b83766c3c26b695
MD5 278391713f7473aa28bac9f85832151b
BLAKE2b-256 9fdc503d141bcae744e1fb882f0ee13950724830245954f02480570093f3e469

See more details on using hashes here.

File details

Details for the file sync_openweatherapi_python_sdk-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for sync_openweatherapi_python_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1a364b9767237ef61a3b342b345eda370632d5328e4a0d8aeffaa153f89770cb
MD5 74530b22adedac1e72ce34b4931ab3a5
BLAKE2b-256 77d12e0da7246b1356451d9a8e42e5439ca0da4ca7a3853d1992d32b238b3dea

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page