OpenWeatherMapSharp 3.1.4

dotnet add package OpenWeatherMapSharp --version 3.1.4                
NuGet\Install-Package OpenWeatherMapSharp -Version 3.1.4                
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="OpenWeatherMapSharp" Version="3.1.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OpenWeatherMapSharp --version 3.1.4                
#r "nuget: OpenWeatherMapSharp, 3.1.4"                
#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 OpenWeatherMapSharp as a Cake Addin
#addin nuget:?package=OpenWeatherMapSharp&version=3.1.4

// Install OpenWeatherMapSharp as a Cake Tool
#tool nuget:?package=OpenWeatherMapSharp&version=3.1.4                

OpenWeatherMapSharp

A .NET client wrapper for https://openweathermap.org written in .NET Standard 2.0

Installation

Install the package via NuGet.

Usage

First you need to get a free API key from openweathermap.org. You can create a new account and you will find your API keys here.

You need to create a new instance of OpenWeatherMapService passing in the API key. There is also an interface available, if you are using Dependency Injection.

/// <summary>
///     Gets forecast for a location given its longitude and latitude
/// </summary>
Task<OpenWeatherMapServiceResponse<ForecastRoot>> GetForecastAsync(
    double latitude,
    double longitude,
    LanguageCode language = LanguageCode.EN,
    Unit unit = Unit.Standard);

/// <summary>
///     Gets forecast for a location given its city ID
/// </summary>
[Obsolete]
Task<OpenWeatherMapServiceResponse<ForecastRoot>> GetForecastAsync(
    int cityId,
    LanguageCode language = LanguageCode.EN,
    Unit unit = Unit.Standard);

/// <summary>
///     Gets forecast for a location given its city name
/// </summary>
[Obsolete]
Task<OpenWeatherMapServiceResponse<ForecastRoot>> GetForecastAsync(
    string city,
    LanguageCode language = LanguageCode.EN,
    Unit unit = Unit.Standard);

/// <summary>
///     Gets weather information for a location given its longitude and latitude
/// </summary>
Task<OpenWeatherMapServiceResponse<WeatherRoot>> GetWeatherAsync(
    double latitude,
    double longitude,
    LanguageCode language = LanguageCode.EN,
    Unit unit = Unit.Standard);

/// <summary>
///     Gets weather information for a location given its city ID
/// </summary>
[Obsolete]
Task<OpenWeatherMapServiceResponse<WeatherRoot>> GetWeatherAsync(
    int cityId,
    LanguageCode language = LanguageCode.EN,
    Unit unit = Unit.Standard);

/// <summary>
///     Gets weather information for a location given its city name
/// </summary>
[Obsolete]
Task<OpenWeatherMapServiceResponse<WeatherRoot>> GetWeatherAsync(
    string city,
    LanguageCode language = LanguageCode.EN,
    Unit unit = Unit.Standard);


/// <summary>
///     Gets a list of locations given a query string
/// </summary>
Task<OpenWeatherMapServiceResponse<List<GeocodeInfo>>> GetLocationByNameAsync(
    string query,
    int limit = 5);

/// <summary>
///     Gets location information for a given zip code
/// </summary>
Task<OpenWeatherMapServiceResponse<GeocodeZipInfo>> GetLocationByZipAsync(
    string zipCode);

/// <summary>
///     Gets location information for a given latitude and longitude
/// </summary>
Task<OpenWeatherMapServiceResponse<List<GeocodeInfo>>> GetLocationByLatLonAsync(
    double latitude,
    double longitude,
    int limit = 5);

HINT: Some methods are marked as obsolete, because openweathermap.org marked these methods as depracted. Currently they are all still working, but might be removed in feature releases. They recommend using the methods with latitude and longitude to get the current weather or the forecast.

Sample

Here is a screenshot of a Console Application using the NuGet package to get the current weather for a provided city.

sample

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
3.1.4 617 11/27/2023
3.1.3 454 11/27/2023
3.1.2 501 10/9/2023
3.1.1 529 10/3/2023
3.1.0 530 10/2/2023
3.0.0 509 9/30/2023
2.0.2 1,118 3/12/2021
2.0.1 1,078 9/4/2020
2.0.0 1,011 9/4/2020
1.1.0 2,085 10/18/2017
1.0.1 1,650 9/17/2017
1.0.0 1,754 9/17/2017

- Code improvements
- Add IconName to data model
- Add DateTime information to forcecast data model