|
1 | 1 | # Overview |
2 | 2 |
|
3 | | -PokeKotlin is a [Kotlin](https://kotlinlang.org/) client for |
4 | | -[PokeApi](https://github.com/PokeAPI/pokeapi). |
| 3 | +## Introduction |
5 | 4 |
|
6 | | -Documentation is under construction. For now, see the |
7 | | -[API Reference](./api/index.html). |
| 5 | +PokeKotlin is a modern [Kotlin Multiplatform] client for [PokéAPI]. You can use |
| 6 | +it to integrate all sorts of Pokémon data into your Kotlin projects. |
| 7 | + |
| 8 | +Under the hood, it's built on [Ktor], [Kotlin Serialization], and coroutines. |
| 9 | + |
| 10 | +## Supported platforms |
| 11 | + |
| 12 | +- Kotlin/JVM, including Android |
| 13 | +- Kotlin/JS for browser and Node |
| 14 | +- Kotlin/WASM for browser and Node |
| 15 | +- Kotlin/Native for Linux, Windows, macOS, iOS, tvOS, and watchOS |
| 16 | + |
| 17 | +## Installation |
| 18 | + |
| 19 | +This library is published via [Maven Central], and snapshot builds of `main` are |
| 20 | +additionally available on [GitHub Packages]. |
| 21 | + |
| 22 | +=== "Releases (Maven Central)" |
| 23 | + |
| 24 | + The latest release is **v{{ gradle.release_version }}**. In your Gradle version catalog, add: |
| 25 | + |
| 26 | + ```toml title="libs.versions.toml" |
| 27 | + [libraries] |
| 28 | + pokekotlin = { module = "dev.sargunv.pokekotlin:pokekotlin", version = "{{ gradle.release_version }}" } |
| 29 | + ``` |
| 30 | + |
| 31 | +=== "Snapshots (GitHub Packages)" |
| 32 | + |
| 33 | + !!! warning |
| 34 | + |
| 35 | + The published documentation is for the latest release, and may not match the snapshot |
| 36 | + version. If using snapshots, always refer to the [latest source code][repo] for the most |
| 37 | + accurate information. |
| 38 | + |
| 39 | + First, follow [GitHub's guide][gh-packages-guide] for authenticating to GitHub Packages. Your |
| 40 | + settings.gradle.kts should have something like this: |
| 41 | + |
| 42 | + ```kotlin title="settings.gradle.kts" |
| 43 | + repositories { |
| 44 | + maven { |
| 45 | + url = uri("https://maven.pkg.github.com/pokeapi/pokekotlin") |
| 46 | + credentials { |
| 47 | + username = project.findProperty("gpr.user") as String? ?: System.getenv("GH_USERNAME") |
| 48 | + password = project.findProperty("gpr.key") as String? ?: System.getenv("GH_TOKEN") |
| 49 | + } |
| 50 | + } |
| 51 | + } |
| 52 | + ``` |
| 53 | + |
| 54 | + The latest snapshot is **v{{ gradle.snapshot_version }}**. In your Gradle version catalog, add: |
| 55 | + |
| 56 | + ```toml title="libs.versions.toml" |
| 57 | + [libraries] |
| 58 | + pokekotlin = { module = "dev.sargunv.pokekotlin:pokekotlin", version = "{{ gradle.snapshot_version }}" } |
| 59 | + ``` |
| 60 | + |
| 61 | +In your Gradle build script, add: |
| 62 | + |
| 63 | +```kotlin title="build.gradle.kts" |
| 64 | +commonMain.dependencies { |
| 65 | + implementation(libs.maplibre.compose) |
| 66 | +} |
| 67 | +``` |
| 68 | + |
| 69 | +## Usage |
| 70 | + |
| 71 | +For basic usage, use the global `PokeApi` instance: |
| 72 | + |
| 73 | +```kotlin |
| 74 | +-8<- "src/commonTest/kotlin/dev/sargunv/pokekotlin/example/example.kt:simple" |
| 75 | +``` |
| 76 | + |
| 77 | +By default, the client will connect to the official `https://pokeapi.co/` |
| 78 | +instance and cache results in memory. |
| 79 | + |
| 80 | +If you want to customize the client, create a custom instance of the client: |
| 81 | + |
| 82 | +```kotlin |
| 83 | +-8<- "src/commonTest/kotlin/dev/sargunv/pokekotlin/example/example.kt:custom" |
| 84 | +``` |
| 85 | + |
| 86 | +For further details, see the Dokka [API Reference](./api). |
| 87 | + |
| 88 | +[Kotlin Multiplatform]: https://kotlinlang.org/docs/multiplatform.html |
| 89 | +[PokéAPI]: https://pokeapi.co/ |
| 90 | +[Maven Central]: https://central.sonatype.com/namespace/dev.sargunv.pokekotlin |
| 91 | +[GitHub Packages]: |
| 92 | + https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry |
| 93 | +[gh-packages-guide]: |
| 94 | + https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-gradle-registry#using-a-published-package |
| 95 | +[repo]: https://github.com/pokeapi/pokekotlin |
| 96 | +[Ktor]: https://ktor.io/ |
| 97 | +[Kotlin Serialization]: https://github.com/Kotlin/kotlinx.serialization |
| 98 | +[coroutines]: https://kotlinlang.org/docs/coroutines-guide.html |
0 commit comments