A .Net Standard library for the Open-Meteo API.
This project is still in development. There will be major changes in the codebase.
- Documentation and wiki
- Throw exceptions instead of returning null (v0.2)
Use NuGet Package Manager GUI. Or use NuGet CLI:
dotnet add package OpenMeteo.dotnet
Alternatively you can build this library on your own.
- Clone this repo:
git clone https://github.com/AlienDwarf/open-meteo-dotnet
-
Open the project and build it. The build process will create a .dll file in
/bin/[CONFIGURATION]/netstandard2.1/
-
Add a reference in your own project to the .dll in your own project.
-
Add
using OpenMeteo;
to your class.
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.
This project is open-source under the MIT license.
This library uses the public and free available Open-Meteo API servers. See also: