Weather API

My most recent project. A .NET wrapper/library for SMHIs free weather services, PMP. Written in C# and .NET 4.

The background is that I needed some kind of free weather data for a project. I looked att a few swedish and norwegian services and ended up with a service from SMHI. With this library it’s super-easy to utilize weather data. No need to parse JSON and make HTTP-requests by your self.

New version, 0.2 – 2014-06-18
Changes in this release:

  • Added method <GetForecast(DateTime) to support fetching data for a certain time. Return null if no data available for time.
  • Renamed class <SMHI> to <Weather> to make it a bit more generic
  • Renamed class <TimeSeriesData> to <TimeSeries>

Sample code to access weather data:

//Position to fetch weather for
Position myPosition = new Position() { Latitude = 59.38m, Longitude = 13.49m };

//Create a Weather-object for that position
Weather weather = Weather.Create(myPosition); 

//Get forecast for the closest hour
TimeSeries myWeather = weather.GetCurrentForecast();

//Get some values
decimal currentTemperature = myWeather.Temperature;
int currentWindDirection = myWeather.WindDirection;
decimal currentWindVelocity = myWeather.WindVelocity;

 

More documentation is on the way!

Read more about using SMHIs data here: http://www.smhi.se/klimatdata/Oppna-data/Meteorologiska-data/api-for-vaderprognosdata-1.34233

Download

 

 

One thought on “Weather API

Leave a Reply

Your email address will not be published. Required fields are marked *