SimpleWeather 2.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package SimpleWeather --version 2.0.0                
NuGet\Install-Package SimpleWeather -Version 2.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleWeather" Version="2.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SimpleWeather --version 2.0.0                
#r "nuget: SimpleWeather, 2.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install SimpleWeather as a Cake Addin
#addin nuget:?package=SimpleWeather&version=2.0.0

// Install SimpleWeather as a Cake Tool
#tool nuget:?package=SimpleWeather&version=2.0.0                

SimpleWeather

Summary

This is a <strong>C# (.NET 6)</strong> library that provides simple means of obtaining weather data from the OpenWeatherMap's API.

Status

NuGet Badge

Methods

There are two <strong>asynchronous</strong> methods which return an Object containing all the weather data for a given city: Current weather data:

GetCurrentWeather(string city, string units)

Weather forecast data:

GetWeatherForecast(string city, string units)
GetWeatherForecast(double lat, double lon, string units)

Prerequisites

In order for the library to work you need to have an <strong>appsettings.json</strong> file containing your OpenWeatherMap's API KEY in your project's output directory with the following parameter:

{
  "openWeatherApiKey": "YourKeyGoesHere"
}

Example usage

using SimpleWeather;

var weatherController = new WeatherController();
var currentWeather = await weatherController.GetCurrentWeather("Lovech", "metric");
var weatherForecast = await weatherController.GetWeatherForecast(43.1333, 24.7167);

Console.WriteLine($"The current weather in {currentWeather.City} is {currentWeather.Main.Temperature} degrees with {currentWeather.Weather.Description}.");

Console.WriteLine("The weather forecast for Lovech for the next 7 days is:");

foreach (var day in weatherForecast.Daily)
{
    Console.WriteLine($"The weather for: {day.DT.ToString("d")}");
    Console.WriteLine($"Min temperature: {day.Temperature.Min}");
    Console.WriteLine($"Max temperature: {day.Temperature.Max}");
    Console.WriteLine($"The weather conditions will be: {day.Weather.Description}");
    Console.WriteLine($"Probability for precipitation: {day.PrecipitationProbability}%");
}

This will produce the following result:

The current weather in Lovech is 11.43 degrees with overcast clouds.

The weather forecast for the next 7 days is:

The weather for: 02.04.2022
Min temperature: 7.03
Max temperature: 20.52
The weather conditions will be: heavy intensity rain
Probability for precipitation: 100%
.
.
.
The weather for: 07.04.2022
Min temperature: 9.34
Max temperature: 17.91
The weather conditions will be: moderate rain
Probability for precipitation: 95%

Installation

DISCLAIMER: Plese note that this package is still under development and bugs may be present. If you spot a bug, please open a new Issue

You can install the NuGet library into your project using:

Package Manager:

Install-Package SimpleWeather -Version 2.0.0

.NET CLI:

dotnet add package SimpleWeather --version 2.0.0

License

Copyright © 2022 Ivan Gechev.

This package has MIT license. Refer to the LICENSE for detailed information.

Questions, comments or additions

If you have a feature request or bug report, open a new Issue or send a Pull request.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.5.0 611 4/15/2022
2.0.0 492 3/31/2022
1.0.0 495 3/29/2022

2.0.0: Introducd the ability to get a weather forecast