Skip to main content

noaa-apiroute

Build Release

Python clients for NOAA's weather APIs: the National Weather Service API (api.weather.gov: forecasts, alerts, observations, stations, zones, radar, text products), the AviationWeather.gov Data API (METARs, TAFs, PIREPs, SIGMETs, airports) and the National Water Prediction Service API (river gauges, stage and flow forecasts). They're generated with apiroute from NOAA's published OpenAPI specs and kept current by a weekly build.

  • Two layers: every call works with plain dicts (weather.points.get(...)), and .models returns typed pydantic models (weather.points.models.get(...)).
  • Sync and async: add .aio to any call for the async version.
  • Lazy loading: only the APIs, sections and models you use are imported.
  • Typed: the package ships py.typed.

Installation

pip install noaa-apiroute    # or: uv add noaa-apiroute

It needs Python 3.10 or newer.

Usage

Forecasts, observations and alerts (api.weather.gov)

from noaa_apiroute.weather import WeatherApi

weather = WeatherApi(user_agent="myapp (me@example.com)")

# A forecast starts from a point: it names the forecast office and grid square
point = weather.points.models.get(latitude=39.7456, longitude=-97.0892).properties
forecast = weather.gridpoints.models.forecast(point.grid_id, point.grid_x, point.grid_y)
for period in forecast.properties.periods:
    print(period.name, period.temperature, period.temperature_unit, period.short_forecast)
hourly = weather.gridpoints.models.forecast_hourly(point.grid_id, point.grid_x, point.grid_y)

latest = weather.stations.models.latest_observation("KMCI").properties
print(latest.temperature.value, latest.temperature.unit_code)  # 23.0 wmoUnit:degC

alerts = weather.alerts.models.active(area=["KS", "MO"])  # a GeoJSON FeatureCollection
for alert in alerts.features:
    print(alert.properties.event, alert.properties.headline)

for observation in weather.stations.models.observations_all("KMCI", limit=50):  # every page
    ...
office = await weather.offices.models.aio.get("TOP")
  • Sections: alerts, points, gridpoints, stations, zones, offices, products, radar, radio, aviation, icons and thumbnails, plus weather.glossary(). The spec has no tags, so the sections and method names come from specs/weather.names.json.
  • Pagination: alerts.list_all, stations.list_all, stations.observations_all and zones.stations_all take the same arguments as their one-page twins and iterate every page's features, following weather.gov's pagination.next links. async for works through .aio, .pages() gives whole pages, and itertools.islice or break stops early. The rules are in specs/weather.pagination.yaml.
  • Responses are GeoJSON (application/geo+json), as weather.gov serves by default. The typed models accept enum values the spec doesn't list: a calm hourly period's wind_direction is "".
  • points.stations redirects: the spec documents only a 301. Use gridpoints.stations(point.grid_id, point.grid_x, point.grid_y) instead.

Aviation weather (AviationWeatherApi)

from noaa_apiroute.aviation import AviationWeatherApi

aviation = AviationWeatherApi(user_agent="myapp (me@example.com)")

[metar] = aviation.models.metar(ids="KMCI", format="json")
print(metar.raw_ob, metar.temp, metar.wdir, metar.wspd)
tafs = aviation.models.taf(ids="KMCI,KSTL", format="json")
pireps = aviation.pirep(id="KMCI", distance=200, format="json")  # dicts: see below
sigmets = aviation.airsigmet(format="json")

Every method is on the client: metar, taf, pirep, airsigmet, isigmet, sigmet, gairmet, airmet, tcf, cwa, wind_temp, area_forecast, forecast_discussion, mis, station_info, airport, navaid, fix, feature, obstacle and data_server.

  • Pass format="json". The API's other formats (raw, xml, geojson ...) aren't JSON.
  • Use the dict layer for pirep and airport. Their typed models don't match what the API sends: the spec declares PIREP flight levels and airport coordinates as strings, but they arrive as numbers.

Rivers and floods (WaterApi)

from noaa_apiroute.water import WaterApi

water = WaterApi(user_agent="myapp (me@example.com)")

gauge = water.gauges.models.get("PTTP1")  # Ohio River at Pittsburgh
print(gauge.name, gauge.status.observed.primary, gauge.status.observed.primary_unit)
observed = water.gauges.models.stage_flow_product("PTTP1", "observed")
nearby = water.gauges.list(bbox_xmin=-80.1, bbox_ymin=40.3, bbox_xmax=-79.9, bbox_ymax=40.5)
streamflow = water.reaches.models.streamflow("3764264")

Sections: gauges (list, get, ratings, river_flow, stage_flow, stage_flow_product, river_at_a_glance), reaches (get, streamflow), products and health.

Identifying yourself

NOAA's APIs need no key. But api.weather.gov refuses requests without a User-Agent, and asks for one that names your application and gives a contact, so that NWS can reach you about a problem instead of blocking you. See the NWS API documentation and its FAQ.

Argument
user_agent Sent as User-Agent by every client. Defaults to noaa-apiroute (https://github.com/dougyouch/noaa-apiroute); set your own, such as "myapp (me@example.com)".
api_key Sent as weather.gov's API-Key header. The spec allows it and NWS may require it in the future; it isn't needed today.
base_url Another host, such as a proxy.

Errors raise apiroute.UnexpectedResponse. Its .response carries NOAA's problem details: error.response.json()["detail"]. Retries are off unless you turn them on, for example with weather.with_options(retries=3). For transports, timeouts and other client options, see apiroute's README.

APIs

API Import Docs
National Weather Service API (api.weather.gov) from noaa_apiroute.weather import WeatherApi docs
AviationWeather.gov Data API from noaa_apiroute.aviation import AviationWeatherApi docs
National Water Prediction Service API from noaa_apiroute.water import WaterApi docs

Other NOAA services publish no OpenAPI spec, so they aren't generated here. These include Tides and Currents, NCEI's Climate Data Online and the Space Weather Prediction Center.

How this repository stays up to date

Nothing under src/noaa_apiroute/ is written by hand except auth.py and __init__.py. Everything else is generated from the specs listed in apis.yaml:

  1. Every Monday, the Build workflow does the following:
    • Upgrades apiroute to its newest release.
    • Downloads NOAA's specs into specs/.
    • Regenerates the clients with apiroute generate, applying the name maps (specs/*.names.json) and the pagination rules in specs/.
    • Runs the lint and tests, then the live tests against NOAA's APIs.
  2. If anything changed, it commits the result to main:
    • feat(specs): ... when NOAA changed a spec, which produces a minor release.
    • fix(codegen): ... when only a newer apiroute changed the generated code, which produces a patch release.
  3. Release then tests the commit and adds it to CHANGELOG.md. It tags the commit, publishes the new version to PyPI and creates a GitHub release. No one has to do anything; every merge to main releases the same way.

CI checks every pull request and every release. It lints, runs the tests on Python 3.10 to 3.14, and regenerates from the committed specs to confirm the committed code matches them exactly.

Because specs/ is committed, git log -p specs/ shows exactly what NOAA changed and when.

Development

uv sync
uv run python scripts/generate.py --fetch   # download the latest specs, regenerate
uv run python scripts/generate.py           # regenerate from the committed specs
uv run python scripts/generate.py --only weather
uv run pytest
NOAA_LIVE=1 uv run pytest tests/live        # against NOAA's APIs
uv run ruff check . && uv run ruff format --check .

To add an API:

  1. Add an entry to apis.yaml with its spec URL, docs URL, module, client class and base_class: noaa_apiroute.auth:NoaaAuth.
  2. Run scripts/generate.py --fetch --only <name>.
  3. Add a live test, and commit with feat:.

License

MIT

Metadata

Release files for noaa-apiroute 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for noaa-apiroute 0.1.0
File Size Uploaded Provenance Actions
noaa_apiroute-0.1.0.tar.gz 128.7 kB Without provenance Details for noaa_apiroute-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for noaa-apiroute 0.1.0
File Interpreter ABI Platform Actions
noaa_apiroute-0.1.0-py3-none-any.whl Python 3 none any Details for noaa_apiroute-0.1.0-py3-none-any.whl

Total release size: 411.4 kB

Release files / noaa_apiroute-0.1.0.tar.gz

Download URL noaa_apiroute-0.1.0.tar.gz
Size 128.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e7cac8e93890234dd7290b698e6ff8fa9930b1d13821740ab62d9c1ea7e9f0fa
BLAKE2b-256 checksum
How to use checksums
e365c9bf3f99e8cdc8ebb1a60d9ef2a2f0ccb5c102ead0ede0dcda3bae480613
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / noaa_apiroute-0.1.0-py3-none-any.whl

Download URL noaa_apiroute-0.1.0-py3-none-any.whl
Size 282.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0be16f895e004deff8f8637f699c16b4545612a79f2e542d94a28473c81773d6
BLAKE2b-256 checksum
How to use checksums
e205541979eb52f078941e83863e780ec9b9aa28640a07a80b85bfffe524c7ef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for noaa-apiroute 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page