Octri

Languages

Kotlin

The Kotlin SDK publishes to Maven Central and is the only language besides TypeScript with an HTTP engine choice.

Install

text
implementation 'com.your-org:api-client-kotlin:1.0.0'

Options

OptionValuesDefault
HTTP engineokhttp, ktorokhttp
Client stylefunctions, namespaced, class, class-namespacedfunctions
Argument styleobject, positionalobject
Namespacetags, pathtags
Doc commentsfull, minimalfull
File headeromit, includeomit
Usage examplefull, concisefull

HTTP engine

kotlin
// OkHttp (JVM)
client.newCall(req)

The default. The JVM standard, already present in most Android and server codebases.

Ktor if your users target multiplatform

OkHttp is fine on Android and the server, but it won't build for Kotlin/Native or Kotlin/JS. If your SDK is meant to work anywhere Kotlin runs, ktor is the only option that gets there.

Package name

Same Maven coordinates as Java, and the same groupId ownership requirement:

text
com.acme:api-client-kotlin

Kotlin and Java both publish to Maven Central, so give them distinct artifactIds. Set Package name rather than a single project-wide name.

What callers write

kotlin
import com.acme.AcmeClient

val client = AcmeClient(token = System.getenv("ACME_TOKEN"))

client.users.list(limit = 100).collect { user ->
    println(user.id)
}