- First install .NET Core >= 2.0 for your platform.
- Install the OpenWeatherMap4NET NuGet Package.
- Request an API key from openweathermap.org
Here is a short usage example for using the service to request the temperature information for 'London':
// build the service
var service = new OpenWeatherMapService(new OpenWeatherMapOptions
{
ApiKey = "[INSERT OPENWEATHERMAP.ORG TOKEN HERE]"
});
// set global unit to Metric, so temperatures are in Celsius and speed units in meter/sec.
RequestOptions.Default.Unit = UnitType.Metric;
// request weather information for "London"
var weather = await service.GetCurrentWeatherAsync("London");
// print out current temperature
Console.WriteLine(weather.Temperature.Value); // -> 20,4
- System.Runtime.Caching (used for internal request caching)
- Newtonsoft.Json (used for HTTP payload deserialization)