OpenWeatherMapSharp 3.1.0
See the version list below for details.
dotnet add package OpenWeatherMapSharp --version 3.1.0
NuGet\Install-Package OpenWeatherMapSharp -Version 3.1.0
<PackageReference Include="OpenWeatherMapSharp" Version="3.1.0" />
paket add OpenWeatherMapSharp --version 3.1.0
#r "nuget: OpenWeatherMapSharp, 3.1.0"
// Install OpenWeatherMapSharp as a Cake Addin #addin nuget:?package=OpenWeatherMapSharp&version=3.1.0 // Install OpenWeatherMapSharp as a Cake Tool #tool nuget:?package=OpenWeatherMapSharp&version=3.1.0
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.
Product | Versions 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. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
- New API endpoints to get the geolocation by name, zip code or latitude/longitude
- Code improvements