How to Get Current Weather via Web Services

Brandon picture Brandon · Mar 17, 2010 · Viewed 16.2k times · Source

I am attempting to get the current weather given a zip code or a set of latitude/longitude coordinates. It appears that best practice to do this (and how NOAA does it) is to get the XML feed for a weather station.

Example: http://www.weather.gov/xml/current_obs/KEDW.xml

The only problem is that NOAA doesn't provide a good way to find the closest weather station given a zip code or coordinates and I did not see any hosted web services out there that will provide this mapping.

Does anyone know of any web services to get the nearest weather station given a zip code or coordinate input? If not, does anyone have any great solutions to look into that provide similar information as NOAA does but takes in a zip code or coordinates?

Answer

davidtbernal picture davidtbernal · Mar 17, 2010

There are numerous weather APIs out there that will look up the weather based on zip codes, or find the nearest one for a zip code. See this question.

The national weather service has a REST API. CTRL+F for zipcode:

Summarized Data for One or More Zipcodes: Returns DWML-encoded NDFD data for one or more zip codes (50 United States and Puerto Rico).

Here is a sample request


I'm not sure if that one has current conditions. If not, you can use the Wunderground API. First you use GeolookupXML to look up nearby weather stations based on the city (see the nearby_weather_stations element in the sample output), then you can use WXCurrentObXML to get the conditions at one of the weather stations.