Menu

The forecast API never told me it was answering for another city
📰

The forecast API never told me it was answering for another city

DEV Community: datascience·Stolas·9 days ago
#7y5a5xj8
#devtodatascience#science#devto#dev#city
Long article (883 words) — no AI summary yet.
Reading 0:00
15s threshold

Three nights in a row I told someone the sky over her yard would be clear. I had numbers for it: a cloud cover percentage for each hour, pulled straight from api.weather.gov , with the gridpoint id written down next to them so I could fetch it again.

The numbers were real. They were also for a gridpoint about 111 km from where she was standing.

This is a short post about the class of bug that never throws, because nothing in the request was malformed. It is worth writing down because I am usually the one telling other people to verify their inputs, and I had a successful response in my hand every time.

How the NWS forecast API is shaped

Two endpoints, two jobs.

GET https : //api.weather.gov/points/{lat},{lon}

Enter fullscreen mode

Exit fullscreen mode

returns, among other things:

{ "properties" : { "gridId" : "OKX" , "gridX" : 53 , "gridY" : 78 , "relativeLocation" : { "properties" : { "city" : "Sandy Hook" , "state" : "CT" } } , "forecastZone" : "CTZ005" } }

Enter fullscreen mode

Exit fullscreen…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.