openweather-kt is a simple Kotlin wrapper for Current Weather API by OpenWeatherMap.
val api = openWeatherApi {
key = OWM_API_KEY
units = Units.IMPERIAL
}
val forecast = api.fromName("cupertino") // throws IllegalArgumentException if nothing has been found
println(forecast.wind.directionName)
val api = openWeatherApi(OWM_API_KEY, language = Languages.RUSSIAN)
val forecast = api.fromNameOrNull("London")
val temperature = forecast?.temperature?.convertUnitsTo(TemperatureUnit.CELCIUS_DEGREE)
println("${temperature?.temperature ?: 0}${temperature?.unit?.symbol ?: "K"}")
Replace VERSION keyword with the latest commit or the latest release in the master
branch.
repositories {
jcenter()
mavenCentral()
maven {
name = "jitpack"
url = uri("https://jitpack.io")
}
}
dependencies {
implementation(group = "com.github.ileukocyte", name = "openweather-kt", version = "VERSION")
}
repositories {
jcenter()
mavenCentral()
maven {
name 'jitpack'
url 'https://jitpack.io'
}
}
dependencies {
compile "com.github.ileukocyte:openweather-kt:VERSION"
}
<dependencies>
<dependency>
<groupId>com.github.ileukocyte</groupId>
<artifactId>openweather-kt</artifactId>
<version>VERSION</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>