☁️ Open-Meteo Kotlin Library

Kotlin Stability: AlphaGitHub license: MITJitpack.io Version

A Kotlin library for the Open-Meteo.com APIs.

This library would be (nearly) useless without the public API servers: please, consider sponsoring open-meteo on GitHub.


⚠️ Warning

Because it’s still in early development, some breaking changes WILL occur. Using the library is discouraged until a version 1.0.0 is published: single commits could break code and remove some features.


? Installation

The library is published on jitpack.io. Please note that a custom domain for the group id is used: it’s an “alias” for com.github.open-meteo.

Gradle

  1. Add the JitPack repository to your root build.gradle file:

allprojects {
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
  1. Add the dependency:

dependencies {
	implementation 'com.open-meteo:open-meteo-api-kotlin:0.0.2-beta.2'
}

Android

  1. Add the JitPack repository to your settings.gradle file:

dependencyResolutionManagement {
	...
	repositories {
		...
		maven { url 'https://jitpack.io' }
	}
}
  1. Add the dependency:

dependencies {
	implementation 'com.open-meteo:open-meteo-api-kotlin:0.0.2-beta.2'
}

Maven

  1. Add the JitPack repository to your build file:

<repositories>
	<repository>
		<id>jitpack.io</id>
		<url>https://jitpack.io</url>
	</repository>
</repositories>
  1. Add the dependency:

<dependency>
	<groupId>com.open-meteo</groupId>
	<artifactId>open-meteo-api-kotlin</artifactId>
	<version>0.0.2-beta.2</version>
</dependency>

? Usage

Here’s a quick example:

import com.openmeteo.api.forecast.ForecastEndpoint
import com.openmeteo.api.forecast.params.*

val forecastEndpoint = ForecastEndpoint()
// you can call the invoke method with `()`
val response = forecastEndpoint(
	hourly = listOf(
		Hourly.weathercode,
		Hourly.temperature_2m,
	),
)
val hourly = response.hourly!! // don't throw in production, this is just an example
val weatherCode = hourly.weathercode!! 
println(weatherCode[0])

Please note that some arrays may be filled with nulls, hence you might want to use ?.get(0) instead. Research is going to be done to find out which array could have nulls and reduce uncertainties.

The library will include some useful examples in the tests and the documentation.

? Analysis

Versioning

The Semantic Versioning standard is used.

? TODO

A dedicated Github project is used to keep organized.

⚖️ Legal

You are free to do pretty much whatever you want with this library, as long as you honour the LICENSE and the ATTRIBUTIONS.

GitHub

View Github