Skip to main content

A Python 3 client for retrieving data from the NWS Weather Forecast API

Project description

nwswx

A Python 3 client for retrieving data from the NWS Weather Forecast API.

Installation

pip install nwswx

Requirements

Package Build Requirements

The full list of packages required to build this module can be found in requirements.txt

Documentation

Full documentation, including examples and an API reference: http://nwswx.readthedocs.io

Examples

Get forecast for a point in GeoJSON format:

>>> import nwswx
>>> nws = nwswx.WxAPI('your@email.com')
>>> forecast = nws.point_forecast(39.0693, -94.6716)
>>> print(forecast)
{
    "@context": [
        "https://raw.githubusercontent.com/geojson/geojson-ld/master/contexts/geojson-base.jsonld",
        {
            "wx": "https://api.weather.gov/ontology#",
            "geo": "http://www.opengis.net/ont/geosparql#",
            "unit": "http://codes.wmo.int/common/unit/",
            "@vocab": "https://api.weather.gov/ontology#"
        }
    ], ...

Get forecast for a point in JSON-LD format:

>>> import nwswx
>>> nws = nwswx.WxAPI('your@email.com')
>>> forecast = nws.point_forecast(39.0693, -94.6716, return_format=nwswx.formats.JSONLD)
>>> print(forecast['periods'])
[{'number': 1, 'name': 'Tonight', 'startTime': '2019-01-13T22:00:00-08:00', 'endTime':
'2019-01-14T06:00:00-08:00', 'isDaytime': False, 'temperature': 28, 'temperatureUnit':
'F', 'temperatureTrend': None, 'windSpeed': '2 to 6 mph', 'windDirection': 'N',
'icon': 'https://api.weather.gov/icons/land/night/few?size=medium', 'shortForecast':
'Mostly Clear', 'detailedForecast': 'Mostly clear, with a low around 28. North wind 2
to 6 mph.'}, ...

Get an hourly forecast for a point in JSON-LD format:

>>> import nwswx
>>> nws = nwswx.WxAPI('your@email.com')
>>> forecast = nws.point_hourly_forecast(39.0693, -94.6716, return_format=nwswx.formats.JSONLD)
>>> print(forecast['periods'])
[{'number': 1, 'name': '', 'startTime': '2019-01-16T19:00:00-08:00', 'endTime':
'2019-01-16T20:00:00-08:00', 'isDaytime': False, 'temperature': 42,
'temperatureUnit': 'F', 'temperatureTrend': None, 'windSpeed': '10 mph', 'windDirection':
'NE', 'icon': 'https://api.weather.gov/icons/land/night/rain,90?size=small',
'shortForecast': 'Light Rain', 'detailedForecast': ''}, ...

Get active weather alerts for a point in ATOM format:

>>> import nwswx
>>> nws = nwswx.WxAPI('your@email.com')
>>> alerts = nws.active_alerts({'point': '39.0693,-94.6716'}, return_format=nwswx.formats.ATOM)
>>> print(alerts)
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:cap="urn:oasis:names:tc:emergency:cap:1.2">
 <id>https://api.weather.gov/alerts?point=39.0693%2C-94.6716&amp;active=1&amp;zone=KSZ104%2CKSC209</id>
 <generator>NWS CAP Server</generator>
 <updated>2019-01-17T06:04:28+00:00</updated>
 <author>
  <name>w-nws.webmaster@noaa.gov</name>
 </author>
 <title>current watches, warnings, and advisories for 39.0693 N, 94.6716 W</title>
 <link rel="self" href="https://api.weather.gov/alerts?point=39.0693%2C-94.6716&amp;active=1&amp;zone=KSZ104%2CKSC209"/>
 <entry>
  <id>https://api.weather.gov/alerts/NWS-IDP-PROD-3320294-2901037</id>
  <link rel="alternate" href="https://api.weather.gov/alerts/NWS-IDP-PROD-3320294-2901037"/>
  <updated>2019-01-16T14:52:00-06:00</updated>
  <published>2019-01-16T14:52:00-06:00</published>
  <author>
   <name>NWS</name>
  </author>
  <title>Winter Weather Advisory issued January 16 at 2:52PM CST expiring January 17 at 9:00AM CST by NWS Kansas City/Pleasant HIll MO</title>
...

Limitations, of Which There Are Many

The following list of endpoints have not been implemented:

  • /stations
  • /stations/{stationId}
  • /stations/{stationId}/observations
  • /stations/{stationId}/observations/current
  • /stations/{stationId}/observations/{recordId}
  • /products/{productId}
  • /products/types
  • /products/types/{typeId}
  • /products/types/{typeId}/locations
  • /products/types/{typeId}/locations/{locationId}
  • /products/locations
  • /products/locations/{locationId}/types
  • /offices/{officeId}
  • /zones/{type}/{zoneId}
  • /zones/{type}/{zoneId}/forecast
  • /alerts/active/count
  • /alerts/active/zone/{zoneId}
  • /alerts/active/area/{area}
  • /alerts/active/region/{region}

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

nwswx-0.1.1.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

nwswx-0.1.1-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file nwswx-0.1.1.tar.gz.

File metadata

  • Download URL: nwswx-0.1.1.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for nwswx-0.1.1.tar.gz
Algorithm Hash digest
SHA256 299f7ae6ada27b0de49657bed4f683023b8a58eb3e0d5be8881cb5db8785af4d
MD5 3aa3baf43c12534b9f309f8ec7ad458e
BLAKE2b-256 d4adec010876b81fa45abd90dacd44ccf528be1bf881bf33c72c5e081aaccbd5

See more details on using hashes here.

File details

Details for the file nwswx-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: nwswx-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.1 CPython/3.6.7

File hashes

Hashes for nwswx-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 95aae12553f3205910e12062c58b7b5bbf745ac2874570134b6eb1565a561ddc
MD5 1ce44d2865c542d6c23c72c2ba7ad592
BLAKE2b-256 accabbdc89626de71abfae168f62390d90544060c275ec339417fe5f37546d47

See more details on using hashes here.

Supported by

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