Skip to content

headzoo/weather-api-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Weather API client (fetch_weather)

Small, dependency-light Python wrapper around WeatherAPI.com to fetch current weather by city.

Install

From GitHub

Once you push this repo to GitHub, other people can install it directly:

python -m pip install "git+https://github.com/headzoo/weather-api-python.git"

From source (local dev)

python -m pip install -e ".[dev]"

Usage

Set your API key:

export WEATHERAPI_KEY="..."

Call the function:

from weather_api_python.weather import WeatherAPI

client = WeatherAPI(api_key="test")
data = fetch_weather("Austin")
print(data["temp_f"], data["condition"])

Errors

Network/API problems raise WeatherAPIError:

from weather_api_python.weather import WeatherAPIError, fetch_weather

try:
    fetch_weather("Austin")
except WeatherAPIError as e:
    print("Weather error:", e)

Running Tests

To run the tests, you'll need pytest, which is included if you install the dev dependencies:

pytest -m pytest

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages