Looking at the api documentation found HERE and HERE, you are calling the /gridpoints/{wfo}/{x},{y}/forecast/hourly call which will return the hourly weather forecast for the specified weather office {wfo} at the specified x-y coordinates. You can find a list of the weather offices HERE. Finding the X-Y coordinates for the weather offices may be a bit more tedious to find on the web.
If you happen have access to the GPS coordinates that you are working with you can use the /points/{x},{y} API call to get the information on the closest weather office to then pass to the /gridpoints/{wfo}/{x},{y}/forecast/hourly API call.
The flow of your application can look something like this:
Step 1: Get your map Geo coordinates. In my case, I am at 35,-106
Step 2: Make a call to the weather.gov API: https://api.weather.gov/points/35,-106. You will be presented with some JSON data. Look for the cwa key in the properties object. That will be the forecast office to pass into the next api call. In my case, the key is ABQ. You also need to find the gridX and gridY keys in the properties. These are the XY coordinates that you will use for the {X},{Y} parameters in the API call. In my case X = 121 and Y = 112.
Step 3: Make the final call to the weather.gov API: https://api.weather.gov/gridpoints/ABQ/121,112/forecast/hourly
Answer from Joshua Espana on Stack Overflowjson - How do I get the hourly forecast from api.weather.gov for Texas stations or zones or offices or gridpoints or anything else? - Stack Overflow
Weather.gov API wrapper
Best API or DB for historical weather?
Looking for archive data of US weather.gov warnings
Looking at the api documentation found HERE and HERE, you are calling the /gridpoints/{wfo}/{x},{y}/forecast/hourly call which will return the hourly weather forecast for the specified weather office {wfo} at the specified x-y coordinates. You can find a list of the weather offices HERE. Finding the X-Y coordinates for the weather offices may be a bit more tedious to find on the web.
If you happen have access to the GPS coordinates that you are working with you can use the /points/{x},{y} API call to get the information on the closest weather office to then pass to the /gridpoints/{wfo}/{x},{y}/forecast/hourly API call.
The flow of your application can look something like this:
Step 1: Get your map Geo coordinates. In my case, I am at 35,-106
Step 2: Make a call to the weather.gov API: https://api.weather.gov/points/35,-106. You will be presented with some JSON data. Look for the cwa key in the properties object. That will be the forecast office to pass into the next api call. In my case, the key is ABQ. You also need to find the gridX and gridY keys in the properties. These are the XY coordinates that you will use for the {X},{Y} parameters in the API call. In my case X = 121 and Y = 112.
Step 3: Make the final call to the weather.gov API: https://api.weather.gov/gridpoints/ABQ/121,112/forecast/hourly
As long as you have the latitude/longitude of the location you want the forecast for, then:
- Get the point metadata from https://api.weather.gov/points/{lat},{lon}
- Follow the link in the
forecastHourlyproperty to get the forecast
This is preferable to constructing the URL as in the other answer, as your program won't break if the URL scheme changes in the future.
Hey there r/Python. Watched a random netflix show about the government and realized that Weather.gov is a free, mostly untapped resource for accurate weather data that doesn't try and sell your data when you use it like The Weather Channel, Accuweather, or Weatherbug. After looking for a bit I couldn't find a package that utilized weather.gov so I decided to write it myself.
PyPi : https://pypi.org/project/weather-gov/0.1/
Source: https://github.com/spectrshiv/python-weather_gov
I've been writing python for internal use for quite a while, but this is my first real public project I've actually put some thought into and followed through on. I appreciate any feedback you guys have.
Licensed under GPLv3.