Weather Underground Web API using C#, Part 1

In the off hours, I’ve been teaching myself C#…a simple enough object oriented language, with the benefit of using the .NET framework. If you’re targeting Windows, it’s incredibly easy…features like file IO and serial port communications work effortlessly.

I have a list of tasks that I complete before I refer to myself as ‘capable’ in a new language:

  • Helloworld
  • Web API Access
  • File IO
  • XML Parsing
  • GUI Creation
  • Serial Communication
  • System Call
  • Directory Management
  • Database Connectivity
  • 3rd Party Library Integration
  • Error Catching/Mitigation
  • Logging

I complete some of the above by using C# to access the Weather Underground’s API, and pull down current weather information for places I’ve lived. If you’re looking to use this code, you’ll have to go to the API website and request a key.

Using Visual Studio Express 2012 create a new console application. I added some lines to frame the start and end of the program.


Parse XML
I create a method called ‘parse’ that performs the following:

  1. Takes a Wunderground query URL (e.g. “”) as input
  2. Requests the data from Wunderground.
  3. Parses the XML file for pertinent weather data.
  4. Prints the data out to the console.


Below is a screenshot of weather data for five different places I’ve lived…


Full Code
Full project file for Visual Studio can be found here: Wunderground_API_Test.

Leave a Reply