Brief Look At National Weather Service Web API

I’ve started exploring Node-RED and I like what I see. It’s a different approach to solving some problems and it’s always nice to have tools in the toolbox that would serve specific needs better than anything I had available before. The second tutorial introduced interacting with REST APIs on the web by querying for earthquake data, which was fun.

But while interesting and informative, there’s nothing I do differently after seeing earthquake data. Weather data, on the other hand, is a different story. As of this writing we’re living through a heat wave, and knowing the forecast daily highs and lows does affect my decisions. For example, whether to use my home air conditioning to pre-cool the house in the morning, which supposedly helps reduce load on the electric grid in the peak afternoon hours.

So I went looking for weather information and found a lot of taxpayer funded resources at the National Weather Service (NWS). Much of which is available as web service APIs. But in order to get data applicable to myself, I first need to figure out how to identify my location in the form of their grid system.

After a few false starts, I found my starting point (literally) in the points endpoint, which returns a set of metadata relevant to the given longitude and latitude. The metadata includes the applicable grid type as well as the X and Y coordinates corresponding to the given latitude and longitude. There are a lot of ways to get usable lat/long values, I went to the Wikipedia page for my city.

Once armed with the gridId, gridX, and gridY values, I could use them to query the remaining endpoints, such as asking for weather forecast for my grid. There’s a wealth of information here that can be a lot of fun for a future project, possibly for a smart home concept of some sort, but right now I should set aside this distraction and return to learning Node-RED.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s