One of our most versatile functions of the Mesonet API is the stations/nearesttime?
service. This service allows you to make powerful queries for both time and location.
The base URL for this feature is: http://api.mesowest.net/v2/stations/nearesttime?
.
The benefit of the /nearesttime?
is the ability to query the observations around a particular date and time. The only required parameter (other than an API token) is &attime=YYYYMMDDhhmm
, with the date string being the time for which you want the observations to be returned. Building on what we have, you can also add the query string &within=60
which will return all observations for 60 minutes before and after the time specified by &attime
.
Pro tip, you can query a defined range both before and after the &attime
. By passing &within=20,15
you would get the closest time within 20 minutes before and 15 after the attime
.
You can further customize your query by adding additional parameters to filter the data in terms of variables, location, or units. For even more versatility in using the /stations/nearestime?
feature, see our blog post on utilizing the Location Services of the API or our API documentation.
Example Queries:
Query all observations, within 25 miles of Salt Lake Airport, for when a tornado hit Salt Lake City on August 11, 1999:
http://api.mesowest.net/v2/stations/nearesttime?&token=demotoken&radius=kslc,25&attime=199908111855&within=60&units=english,speed|mph
Get the wind gust speeds when Hurricane Sandy made landfall in New Jersey on October 29, 2012:
http://api.mesowest.net/v2/stations/nearesttime?&token=demotoken&state=nj&attime=201210300300&within=120&vars=wind_gust