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) Output:: { "@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']) Output:: [{'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']) Output:: [{'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) Output:: https://api.weather.gov/alerts?point=39.0693%2C-94.6716&active=1&zone=KSZ104%2CKSC209 NWS CAP Server 2019-01-17T06:04:28+00:00 w-nws.webmaster@noaa.gov current watches, warnings, and advisories for 39.0693 N, 94.6716 W https://api.weather.gov/alerts/NWS-IDP-PROD-3320294-2901037 2019-01-16T14:52:00-06:00 2019-01-16T14:52:00-06:00 NWS Winter Weather Advisory issued January 16 at 2:52PM CST expiring January 17 at 9:00AM CST by NWS Kansas City/Pleasant HIll MO ...