Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the hourly forecast from api.weather.gov for Texas stations or zones or offices or gridpoints or anything else?

Tags:

json

I am trying to get the hourly forecast from api.weather.gov

I have one gridpoint working for Indiana. https://api.weather.gov/gridpoints/IND/56,65/forecast/hourly

I was given this information and it is valid. What I need is the hourly forecast in the state of Texas for every stations or zones or offices or gridpoints or anything else.

How do I do that?

like image 819
Gurthang99 Avatar asked Dec 29 '25 04:12

Gurthang99


2 Answers

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

like image 175
Joshua Espana Avatar answered Jan 04 '26 02:01

Joshua Espana


As long as you have the latitude/longitude of the location you want the forecast for, then:

  1. Get the point metadata from https://api.weather.gov/points/{lat},{lon}
  2. Follow the link in the forecastHourly property 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.

like image 44
Stephen Clouse Avatar answered Jan 04 '26 04:01

Stephen Clouse



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!