Python Windy API package for interacting with the Windy API.
Project description
Windy API
Python Windy API package for interacting with the Windy API. Currently only supports access to the point forecast API.
Installation
python -m pip install windy_api
From source:
git clone https://github.com/stedonnelly/windy-api
cd windy-api
python -m pip install .
Usage
Quick Start
from windy_api import WindyAPI
# Initialize the client with your API key
api = WindyAPI(api_key="your_api_key_here")
# Get point forecast for San Francisco
response = api.get_point_forecast(
latitude=37.7749,
longitude=-122.4194,
model="gfs",
parameters=["temp", "wind"]
)
# Access forecast data
print(f"Timestamps: {response.ts}")
print(f"Temperature data: {response.get_data('temp-surface')}")
print(f"Temperature unit: {response.get_unit('temp-surface')}")
Available Weather Models
The following weather forecast models are supported:
gfs- Global Forecast System (default)iconeu- ICON EU regional modelgfs_wave- GFS Wave modelnamconus- NAM CONUS regional modelnamhawaii- NAM Hawaii regional modelnamalaska- NAM Alaska regional modelcams- CAMS air quality model
Available Parameters
Common weather parameters you can request:
temp- Temperaturewind- Wind speed and direction (returnswind_uandwind_vcomponents)windGust- Wind gustsdewpoint- Dew point temperatureprecip- PrecipitationconvPrecip- Convective precipitationsnowPrecip- Snow precipitationcape- Convective Available Potential Energypressure- Atmospheric pressurerh- Relative humiditylclouds,mclouds,hclouds- Low/medium/high cloudsgh- Geopotential heightptype- Precipitation type
Detailed Examples
Multiple Parameters
# Request multiple weather parameters
response = api.get_point_forecast(
latitude=40.7128,
longitude=-74.0060,
model="gfs",
parameters=["temp", "dewpoint", "pressure", "rh", "precip"]
)
# Access each parameter
for timestamp in response.ts:
print(f"Time: {timestamp}")
temp_data = response.get_data("temp-surface")
dewpoint_data = response.get_data("dewpoint-surface")
pressure_data = response.get_data("pressure-surface")
Working with Wind Data
# Wind returns u and v components
response = api.get_point_forecast(
latitude=51.5074,
longitude=-0.1278,
model="gfs",
parameters=["wind", "windGust"]
)
# Get wind components
wind_u = response.get_data("wind_u-surface") # East-west component
wind_v = response.get_data("wind_v-surface") # North-south component
wind_gust = response.get_data("windGust-surface")
Async Usage
import asyncio
from windy_api import WindyAPI
async def get_forecasts():
api = WindyAPI(api_key="your_api_key_here")
# Fetch multiple locations concurrently
responses = await asyncio.gather(
api.get_point_forecast_async(37.7749, -122.4194, "gfs", ["temp"]),
api.get_point_forecast_async(40.7128, -74.0060, "gfs", ["temp"]),
api.get_point_forecast_async(51.5074, -0.1278, "gfs", ["temp"])
)
return responses
# Run the async function
responses = asyncio.run(get_forecasts())
Using Environment Variables for API Key
import os
from dotenv import load_dotenv
from windy_api import WindyAPI
# Load API key from .env file
load_dotenv()
api = WindyAPI(api_key=os.getenv("WINDY_API_KEY"))
response = api.get_point_forecast(
latitude=48.8566,
longitude=2.3522,
model="iconeu", # Use ICON EU model for Europe
parameters=["temp", "precip", "wind"]
)
Error Handling
from httpx import HTTPStatusError
try:
response = api.get_point_forecast(
latitude=37.7749,
longitude=-122.4194,
model="gfs",
parameters=["temp"]
)
except HTTPStatusError as e:
print(f"API request failed: {e.response.status_code}")
print(f"Response: {e.response.text}")
except ValueError as e:
print(f"Invalid parameters: {e}")
Getting Your API Key
To use this library, you need a Windy API key. Visit Windy API to register and obtain your API key.
Contributing
See CONTRIBUTING.md for instructions on how to contribute.
License
Distributed under the terms of the MIT license.
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 windy_api-0.1b2.tar.gz.
File metadata
- Download URL: windy_api-0.1b2.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f7c362a80702d8d4484a27489791a51f5d28fd974e3ed8fb54850cd038af439
|
|
| MD5 |
44cfd417342826eac3625abd64fd6867
|
|
| BLAKE2b-256 |
ed6337f53bf512906bf2ee825e09d99176e68a2370ef4b6045d21d6b0b95c3ed
|
Provenance
The following attestation bundles were made for windy_api-0.1b2.tar.gz:
Publisher:
cd.yml on stedonnelly/windy-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
windy_api-0.1b2.tar.gz -
Subject digest:
7f7c362a80702d8d4484a27489791a51f5d28fd974e3ed8fb54850cd038af439 - Sigstore transparency entry: 701272809
- Sigstore integration time:
-
Permalink:
stedonnelly/windy-api@9759307a4805e0ac498d922b93479a4ef89b0f1c -
Branch / Tag:
refs/tags/v0.1b2 - Owner: https://github.com/stedonnelly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@9759307a4805e0ac498d922b93479a4ef89b0f1c -
Trigger Event:
release
-
Statement type:
File details
Details for the file windy_api-0.1b2-py3-none-any.whl.
File metadata
- Download URL: windy_api-0.1b2-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f25f40199c12d4b9407bf58f8d0afd6a0efa402a5ec7a054a87e5c4a141776c
|
|
| MD5 |
9fbf8e2e969a629570de770b4a078a7e
|
|
| BLAKE2b-256 |
9bc5bd50e59e0ee036a65d370bc4269b5a14f50c4ab0b9619ae39f5275a99198
|
Provenance
The following attestation bundles were made for windy_api-0.1b2-py3-none-any.whl:
Publisher:
cd.yml on stedonnelly/windy-api
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
windy_api-0.1b2-py3-none-any.whl -
Subject digest:
8f25f40199c12d4b9407bf58f8d0afd6a0efa402a5ec7a054a87e5c4a141776c - Sigstore transparency entry: 701272843
- Sigstore integration time:
-
Permalink:
stedonnelly/windy-api@9759307a4805e0ac498d922b93479a4ef89b0f1c -
Branch / Tag:
refs/tags/v0.1b2 - Owner: https://github.com/stedonnelly
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@9759307a4805e0ac498d922b93479a4ef89b0f1c -
Trigger Event:
release
-
Statement type: