Open-Meteo Android Library

An Android library for the Open-Meteo APIs written in Kotlin.

Usage

The library includes some examples in the implementation tests; Here’s a quick example for the Forecast API:

// import com.github.dadibit.openmeteo.ForecastApi

val forecastApi = ForecastApi()
val forecast = forecastApi.fetch(
	hourly = listOf(
		Hourly.weathercode,
		Hourly.temperature_2m,
	),
)
forecast ?: return
val hourly = forecast
	.getJSONObject("hourly")
val times = hourly
	.getJSONArray("time")
val weatherCodes = hourly
	.getJSONArray("weathercode")
val temperatures = hourly
	.getJSONArray("temperature_2m")
val temperatures_unit = forecast
	.getJSONObject("hourly_units")
	.getString("temperature_2m")
// JSON arrays are not iterable
for (i in 0..167) {
	val time = times.getString(i)
	val weatherCode = ForecastApi
		.WeatherCode.parse(weatherCodes.getInt(i))
	val temperature = temperatures.getDouble(i)
	println("$time: $weatherCode / $temperature $temperatures_unit")
}

APIs Implementation

Name Version Last Updated
Weather Forecast API v1 05-08-2022
Historical Weather API v1 05-08-2022
Marine Weather API v1 05-08-2022
Geocoding API v1 05-08-2022
Elevation API v1 05-08-2022
ECMWF Weather Forecast API v1 05-08-2022

TODO

  • Code documentation
  • Wiki documentation
  • Attributions
  • More complete tests
  • Return a dedicated class instead of JSON
  • Create an Android example app
    • CoroutineWorker
    • Widget
  • Publish on jitpack.io
  • Github actions
    • Test if new APIs need to be implementated

GitHub

View Github