Overview¶
Introduction¶
PokeKotlin is a modern Kotlin Multiplatform client for PokéAPI. You can use it to integrate all sorts of Pokémon data into your Kotlin projects.
Under the hood, it's built on Ktor, Kotlin Serialization, and coroutines.
Supported platforms¶
- Kotlin/JVM, including Android
- Kotlin/JS for browser and Node
- Kotlin/WASM for browser and Node
- Kotlin/Native for Linux, Windows, macOS, iOS, tvOS, and watchOS
Installation¶
This library is published via Maven Central, and snapshot builds of main
are
additionally available on GitHub Packages.
The latest release is v3.0.0-pre2. In your Gradle version catalog, add:
[libraries]
pokekotlin = { module = "co.pokeapi.pokekotlin:pokekotlin", version = "3.0.0-pre2" }
Warning
The published documentation is for the latest release, and may not match the snapshot version. If using snapshots, always refer to the latest source code for the most accurate information.
First, follow GitHub's guide for authenticating to GitHub Packages. Your settings.gradle.kts should have something like this:
repositories {
maven {
url = uri("https://maven.pkg.github.com/pokeapi/pokekotlin")
credentials {
username = project.findProperty("gpr.user") as String? ?: System.getenv("GH_USERNAME")
password = project.findProperty("gpr.key") as String? ?: System.getenv("GH_TOKEN")
}
}
}
The latest snapshot is v3.0.1-SNAPSHOT. In your Gradle version catalog, add:
[libraries]
pokekotlin = { module = "co.pokeapi.pokekotlin:pokekotlin", version = "3.0.1-SNAPSHOT" }
In your Gradle build script, add:
commonMain.dependencies {
implementation(libs.maplibre.compose)
}
Usage¶
For basic usage, use the global PokeApi
instance:
val bulbasaur = PokeApi.getPokemon(1)
println(bulbasaur)
By default, the client will connect to the official https://pokeapi.co/
instance and cache results in memory.
If you want to customize the client, create a custom instance of the client:
val client = PokeApi(baseUrl = "https://localhost:8080")
val bulbasaur = client.getPokemon(1)
println(bulbasaur)
For further details, see the Dokka API Reference.