PokeApi
A Kotlin wrapper for pokeapi.co. One generic
get() resolves the endpoint from the entity type you ask for, then maps the
JSON response into a data class.
- Kotlin 2.1
- JVM 17
- MIT
- Endpoints
- 48
- Entity groups
- 11
- Coordinates
- fr.tykok:pokeapi
How it works¶
You never name an endpoint. You name a type, and PokeApi resolves the endpoint from it:
// inside a coroutine
val pikachu = PokeApi.get<Pokemon>(name = "pikachu") // GET /pokemon/pikachu
val cheriBerry = PokeApi.get<Berry>(id = 1) // GET /berry/1
val firstTen = PokeApi.list<Pokemon>(limit = 10, offset = 0) // GET /pokemon?offset=0&limit=10
Every response is mapped into a Kotlin data class, so the compiler — not the JSON — tells you what a
resource contains. Each call above is suspend; a getBlocking/listBlocking counterpart exists for
callers outside a coroutine.
Where to go next¶
- Getting started — add the dependency to Gradle or Maven
- Methods —
get,list, and their blocking counterparts - Configuration — the cache, timeouts, your own
OkHttpClient, andclose() - API Reference — all 48 endpoints, grouped
- Contributing — issues and pull requests welcome