4. Open‐Mateo API - Alienplayer9958/Training-Module---Team-1 GitHub Wiki

What Is Open-Meteo?

Open-Meteo is an open-source weather API that provides weather information that applications can retrieve through web requests.

For this training module, we will use the Open-Meteo Forecast API to retrieve weather information and display it in a .NET MAUI application.

Open-Meteo provides several different types of weather information, including current conditions, hourly forecasts, daily forecasts, and other weather-related data.

API Endpoint

The primary endpoint we will use is:

https://api.open-meteo.com/v1/forecast

An API request can then add parameters to specify the location and information we want.

For example:

https://api.open-meteo.com/v1/forecast?latitude=44.25&longitude=-85.40&current=temperature_2m

Breaking Down the Request

https://api.open-meteo.com/v1/forecast

This is the API endpoint.

latitude=44.25

Specifies the latitude of the requested location.

longitude=-85.40

Specifies the longitude of the requested location.

current=temperature_2m

Specifies that we want the current 2-meter temperature.

The parameters are separated using &.

For example:

?latitude=44.25&longitude=-85.40&current=temperature_2m

Requesting Multiple Variables

Multiple weather variables can be requested at the same time.

For example:

current=temperature_2m,relative_humidity_2m,wind_speed_10m

This allows the application to request several pieces of information with one API request.

JSON Responses

Open-Meteo normally returns API responses as JSON unless another response format is requested.

A response may contain sections such as:

current

hourly

daily

The variables requested from the API determine what information is returned in those sections.

Why Are We Using Open-Meteo?

Open-Meteo is useful for this training because students can make API requests without first creating an API account or configuring an API key. Open-Meteo also provides many different weather variables that can be used to demonstrate how API requests can be customized.