Select to view content in your preferred language

Pull Weather Data API Include Rainfall in Last 24 Hours

315
4
08-22-2024 09:45 AM
ZachBodenner
MVP Regular Contributor

Hello,

I've been working on trying to pull realtime weather data using javascript functions. There have been a few posts about doing this with Survey123 Connect, including using the Open Weather API and  NOAA API. I've gotten both of these to successfully pull data, but my user is requesting a piece of information that does not seem to be present in either of them. I'm looking for an API that includes rainfall (or precipitation generally) amounts within the last 24 hours. Is anyone aware of a weather API that contains this information and possibly have examples of how they've used it in Survey123?

4 Replies
abureaux
MVP Frequent Contributor

Open Weather API sounds like it can pull the last year (EDIT: sorry, they have yearly, monthly, and daily APIs). And their definition of "max" for "precipitation" sounds like it should count.

abureaux_0-1724427935138.png

 

abureaux_1-1724427980201.png

I'm probably missing something though.

0 Kudos
ZachBodenner
MVP Regular Contributor

Thanks! I had come across these actually, and I've gotten the pull to work, but really the issue is that I don't want a daily aggregate, but an aggregate of the previous 24 hours, which is of course unlikely to be a single date (which is how I would structure the API call based on what I read in Open Weather's documentation).

0 Kudos
abureaux
MVP Frequent Contributor

Ohhhh. Gotcha.

Hmm. That isn't typically how these types of records are kept. With the exception of specialty services that keep a running record of "24 hour precipitation", which if they exists are likely to be a very localized service. And since that value changes second-to-second, it would likely be a single value that you would pull. Setting up your own automated rain gauge system would be a good option, but is most likely out of scope.

All I can suggest is try to pull today's precipitation and yesterday's precipitation separately for an approximation of 24 precipitation.

0 Kudos
ZachBodenner
MVP Regular Contributor

Yeah that's kind of what I'm thinking too. Typically my users would consult a local weather station's web page, I think, which is a bit of a different thing to what I've been working with.

0 Kudos