diff --git a/README.md b/README.md index ede7723..dc27b9d 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,12 @@ # OpenWeatherMapSharp -A .NET client wrapper for https://openweathermap.org written in .NET Standard 2.0 - +A .NET client wrapper for [https://openweathermap.org](https://openweathermap.org) written in .NET Standard 2.0 ## Installation Install the package via [NuGet](https://www.nuget.org/packages/OpenWeatherMapSharp). -![Nuget](https://img.shields.io/nuget/v/OpenWeatherMapSharp) - +[![Nuget](https://img.shields.io/nuget/v/OpenWeatherMapSharp)](https://www.nuget.org/packages/OpenWeatherMapSharp) ## Usage @@ -18,7 +16,8 @@ You need to create a new instance of `OpenWeatherMapService` passing in the *API ```csharp /// -/// Gets forecast for a location given its longitude and latitude +/// Gets forecast data for a location based +/// on its geographic coordinates. /// Task> GetForecastAsync( double latitude, @@ -27,7 +26,7 @@ Task> GetForecastAsync( Unit unit = Unit.Standard); /// -/// Gets forecast for a location given its city ID +/// Gets forecast data based on a city ID. /// [Obsolete] Task> GetForecastAsync( @@ -36,7 +35,7 @@ Task> GetForecastAsync( Unit unit = Unit.Standard); /// -/// Gets forecast for a location given its city name +/// Gets forecast data based on a city name. /// [Obsolete] Task> GetForecastAsync( @@ -45,7 +44,7 @@ Task> GetForecastAsync( Unit unit = Unit.Standard); /// -/// Gets weather information for a location given its longitude and latitude +/// Gets current weather data for a location based on its geographic coordinates. /// Task> GetWeatherAsync( double latitude, @@ -54,7 +53,7 @@ Task> GetWeatherAsync( Unit unit = Unit.Standard); /// -/// Gets weather information for a location given its city ID +/// Gets current weather data based on a city ID. /// [Obsolete] Task> GetWeatherAsync( @@ -63,31 +62,74 @@ Task> GetWeatherAsync( Unit unit = Unit.Standard); /// -/// Gets weather information for a location given its city name +/// Gets current weather data based on a city name. /// [Obsolete] Task> GetWeatherAsync( string city, LanguageCode language = LanguageCode.EN, Unit unit = Unit.Standard); + +/// +/// Gets a list of matching locations for a given query string. +/// +Task>> GetLocationByNameAsync( + string query, + int limit = 5); + +/// +/// Gets geolocation information based on a ZIP or postal code. +/// +Task> GetLocationByZipAsync( + string zipCode); + +/// +/// Gets a list of matching locations for a given pair of coordinates. +/// +Task>> GetLocationByLatLonAsync( + double latitude, + double longitude, + int limit = 5); + +/// +/// Retrieves current air pollution data for a specific location. +/// +Task> GetAirPolutionAsync( + double latitude, + double longitude); + +/// +/// Retrieves forecasted air pollution data for the coming days for a specific location. +/// +Task> GetAirPolutionForecastAsync( + double latitude, + double longitude); + +/// +/// Retrieves historical air pollution data for a specific location and time range. +/// +Task> GetAirPolutionHistoryAsync( + double latitude, + double longitude, + DateTime start, + DateTime end); ``` ***HINT:*** Some methods are marked as `obsolete`, because [openweathermap.org](https://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 the `Console Application` using the [NuGet package](https://www.nuget.org/packages/OpenWeatherMapSharp) to get the current weather for a provided city. -![](./docs/openweathermapsharp-sample.png) +![Console Application](./docs/openweathermapsharp-sample.png) ## Buy Me A Coffee -I appreciate any form of support to keep my _Open Source_ activities going. +I appreciate any form of support to keep my *Open Source* activities going. Whatever you decide, be it reading and sharing my blog posts, using my NuGet packages or buying me a coffee/book, thank you ❤️. -Buy Me A Coffee +[![Buy Me A Coffee](https://cdn.buymeacoffee.com/buttons/default-yellow.png)](https://www.buymeacoffee.com/tsjdevapps) ## Contributing @@ -98,4 +140,4 @@ Please make sure to update tests as appropriate. ## License -[MIT](https://choosealicense.com/licenses/mit/) \ No newline at end of file +[MIT](https://choosealicense.com/licenses/mit/) diff --git a/docs/openweathermapsharp-sample.png b/docs/openweathermapsharp-sample.png index 16485ef..646199a 100644 Binary files a/docs/openweathermapsharp-sample.png and b/docs/openweathermapsharp-sample.png differ diff --git a/src/OpenWeatherMapSharp/OpenWeatherMapSharp.csproj b/src/OpenWeatherMapSharp/OpenWeatherMapSharp.csproj index efbce50..d46ed69 100644 --- a/src/OpenWeatherMapSharp/OpenWeatherMapSharp.csproj +++ b/src/OpenWeatherMapSharp/OpenWeatherMapSharp.csproj @@ -2,32 +2,34 @@ netstandard2.0 - False + True OpenWeatherMapSharp - 3.1.4 + 4.0.0 Thomas Sebastian Jensen tsjdev-apps.de An unofficial .NET API wrapper for OpenWeatherMap.org - © Thomas Sebastian Jensen | 2017-2023 + © Thomas Sebastian Jensen | 2017-2025 https://github.com/tsjdev-apps/openweathermap-sharp https://github.com/tsjdev-apps/openweathermap-sharp MIT icon.png OpenWeatherMap; Api; Mock; Wrapper; free; Weather + - Add Air Pollution endpoints + - Update NuGet packages - Code improvements - - Add IconName to data model - - Add DateTime information to forcecast data model en + README.md - + + - + - + diff --git a/src/OpenWeatherMapSharp/README.md b/src/OpenWeatherMapSharp/README.md new file mode 100644 index 0000000..5cea81f --- /dev/null +++ b/src/OpenWeatherMapSharp/README.md @@ -0,0 +1,122 @@ +# OpenWeatherMapSharp + +A .NET client wrapper for [https://openweathermap.org](https://openweathermap.org) written in .NET Standard 2.0 + +## Installation + +Install the package via [NuGet](https://www.nuget.org/packages/OpenWeatherMapSharp). + +[![Nuget](https://img.shields.io/nuget/v/OpenWeatherMapSharp)](https://www.nuget.org/packages/OpenWeatherMapSharp) + +## Usage + +First you need to get a free API key from [openweathermap.org](https://www.openweathermap.org). You can create a new account and you will find your API keys on [your API keys page](https://home.openweathermap.org/api_keys). + +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. + +```csharp +/// +/// Gets forecast data for a location based +/// on its geographic coordinates. +/// +Task> GetForecastAsync( + double latitude, + double longitude, + LanguageCode language = LanguageCode.EN, + Unit unit = Unit.Standard); + +/// +/// Gets forecast data based on a city ID. +/// +[Obsolete] +Task> GetForecastAsync( + int cityId, + LanguageCode language = LanguageCode.EN, + Unit unit = Unit.Standard); + +/// +/// Gets forecast data based on a city name. +/// +[Obsolete] +Task> GetForecastAsync( + string city, + LanguageCode language = LanguageCode.EN, + Unit unit = Unit.Standard); + +/// +/// Gets current weather data for a location based on its geographic coordinates. +/// +Task> GetWeatherAsync( + double latitude, + double longitude, + LanguageCode language = LanguageCode.EN, + Unit unit = Unit.Standard); + +/// +/// Gets current weather data based on a city ID. +/// +[Obsolete] +Task> GetWeatherAsync( + int cityId, + LanguageCode language = LanguageCode.EN, + Unit unit = Unit.Standard); + +/// +/// Gets current weather data based on a city name. +/// +[Obsolete] +Task> GetWeatherAsync( + string city, + LanguageCode language = LanguageCode.EN, + Unit unit = Unit.Standard); + +/// +/// Gets a list of matching locations for a given query string. +/// +Task>> GetLocationByNameAsync( + string query, + int limit = 5); + +/// +/// Gets geolocation information based on a ZIP or postal code. +/// +Task> GetLocationByZipAsync( + string zipCode); + +/// +/// Gets a list of matching locations for a given pair of coordinates. +/// +Task>> GetLocationByLatLonAsync( + double latitude, + double longitude, + int limit = 5); + +/// +/// Retrieves current air pollution data for a specific location. +/// +Task> GetAirPolutionAsync( + double latitude, + double longitude); + +/// +/// Retrieves forecasted air pollution data for the coming days for a specific location. +/// +Task> GetAirPolutionForecastAsync( + double latitude, + double longitude); + +/// +/// Retrieves historical air pollution data for a specific location and time range. +/// +Task> GetAirPolutionHistoryAsync( + double latitude, + double longitude, + DateTime start, + DateTime end); +``` + +***HINT:*** Some methods are marked as `obsolete`, because [openweathermap.org](https://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. + +## License + +[MIT](https://choosealicense.com/licenses/mit/)