Giter Club home page Giter Club logo

open-meteo-dotnet's Introduction

🌡️🌤️ Open-Meteo Dotnet Library

build and test GitHub license Nuget

A .Net Standard library for the Open-Meteo API.

2.0.0 is not compatible with lower versions like 0.2.x!

❕ Information

This project is still in development. There will be major changes in the codebase.

🎯 Roadmap

  • Documentation and wiki
  • Throw exceptions instead of returning null (v0.2)

🔨 Installation/Build

NuGet

NuGet Package

Use NuGet Package Manager GUI. Or use NuGet CLI:

dotnet add package OpenMeteo.dotnet

Build

Alternatively you can build this library on your own.

  1. Clone this repo:
git clone https://github.com/AlienDwarf/open-meteo-dotnet
  1. Open the project and build it. The build process will create a .dll file in /bin/[CONFIGURATION]/netstandard2.1/

  2. Add a reference in your own project to the .dll in your own project.

  3. Add using OpenMeteo; to your class.

💻 Usage

Minimal:

using OpenMeteo;

static void Main()
{
    RunAsync().GetAwaiter().GetResult();
}

static async Task RunAsync()
{
    // Before using the library you have to create a new client. 
    // Once created you can reuse it for every other api call you are going to make. 
    // There is no need to create multiple clients.
    OpenMeteo.OpenMeteoClient client = new OpenMeteo.OpenMeteoClient();

    // Make a new api call to get the current weather in tokyo
    WeatherForecast weatherData = await client.QueryAsync("Tokyo");

    // Output the current weather to console
    Console.WriteLine("Weather in Tokyo: " + weatherData.Current.Temperature + weatherData.CurrentUnits.Temperature);
    
    // Output: "Weather in Tokyo: 28.1°C
}

For more examples visit the Wiki example page.

License

This project is open-source under the MIT license.

Appendix

This library uses the public and free available Open-Meteo API servers. See also:

open-meteo-dotnet's People

Contributors

aliendwarf avatar colinnuk avatar sbiaudet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

open-meteo-dotnet's Issues

Daily and Hourly properties always null

when I try to access the following properties by doing

OpenMeteoClient.Query(city).Daily

or

OpenMeteoClient.Query(city).Hourly

I get null no matter the city.

Version

0.2.8

Additional context

.Net 7.0, ASP.NET project

Returning null results

I have ASP.NET CORE 6 WEB API.

image

Below is my code:

public async Task<ActionResult> GetForecast()
{
_logger.LogInformation("Getting all Forecasts...");

OpenMeteoClient client = new OpenMeteoClient();

HourlyOptionsParameter[] parameters = new HourlyOptionsParameter[]
{
    HourlyOptionsParameter.temperature_2m,
    HourlyOptionsParameter.relativehumidity_2m,
};

Minutely15OptionsParameter[] parameters15Mins = new Minutely15OptionsParameter[]
{
    Minutely15OptionsParameter.temperature_2m,
    Minutely15OptionsParameter.relativehumidity_2m,
    Minutely15OptionsParameter.precipitation,
    Minutely15OptionsParameter.rain,
    Minutely15OptionsParameter.weathercode,
    Minutely15OptionsParameter.windspeed_10m,
    Minutely15OptionsParameter.winddirection_10m,
    Minutely15OptionsParameter.windgusts_10m,
};

WeatherModelOptionsParameter[] modelParameters = new WeatherModelOptionsParameter[]
{
    WeatherModelOptionsParameter.icon_d2
};

// Set custom options
WeatherForecastOptions options = new WeatherForecastOptions();
options.Temperature_Unit = TemperatureUnitType.celsius;
options.Latitude = 45.70108f;
options.Longitude = 14.590678f;
options.Minutely15 = new Minutely15Options(parameters15Mins);
options.Models = new WeatherModelOptions(modelParameters);

// Make a new api call to get the current weather in tokyo
WeatherForecast weatherData = await client.QueryAsync(options);

return Ok(weatherData);

}

Add European AQI and US AQI

European AQI parameters and US AQI parameters are not supported by library.

Parameters available for European AQI :

  • european_aqi
  • european_aqi_pm2_5
  • european_aqi_pm10
  • european_aqi_no2
  • european_aqi_o3
  • european_aqi_so2

Parameters available for US AQI :

  • us_aqi
  • us_aqi_pm2_5
  • us_aqi_pm10
  • us_aqi_no2
  • us_aqi_o3
  • us_aqi_so2
  • us_aqi_co

.NET Standard 2.0 support

Description

I would like to add Open Meteo API support to my UWP weather application

Unfortunately, UWP only supports .NET Standard 2.0

Describe the solution you'd like

Change the TargetFramework and LangVersion of the project

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <PropertyGroup>
    <LangVersion>latestMajor</LangVersion>
  </PropertyGroup>

All unit tests can pass
image

Sync methods for async counterparts

Description

The api currently supports no synchronous calls out of box. For some unknown reasons someone might need those.

Describe the solution you'd like

  • QueryAsync -> Query(Sync)
  • GetWeatherDataAsync -> GetWeatherData(Sync)
    and so on

Tidy up documentation and readme

Description

Make a clear and understandable documentation with examples.

Describe the solution you'd like

  • Code documentation
  • update readme.md
  • Wiki entries with examples
  • Example apps using the api

SDK standardization, FlatBuffer support

Description

Standardize SDKs across all languages.

Describe the solution you'd like

Move all SDKs to open-meteo/sdk with the integration of the FlatBuffer library (currently not available for .NET).
Standardize SDK methods and classes names and structures.

Additional context

I would kindly like to ask you some input on the related issue on the open-meteo-website repo. We're in an early stage of development, so changes can still happen: it's the tight time to find out what could work best for this library/language (if at all possible), in order to make it feasible to standardize all SDKs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.