> For the complete documentation index, see [llms.txt](https://docs.autonomi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.autonomi.com/developers/sdk/install/reference/language-bindings/kotlin.md).

# Kotlin

The Kotlin SDK targets the `antd` daemon over REST or gRPC.

## Install

```kotlin
dependencies {
    implementation("com.autonomi:antd-kotlin:0.1.0")
}
```

Until the package is published, use the project as a local dependency or composite build.

## Connect to the daemon

```kotlin
import com.autonomi.sdk.*
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
    val client = AntdClient.createRest("http://localhost:8082")
    val status = client.health()
    println(status.network)
    client.close()
}
```

## Store and retrieve data

```kotlin
import com.autonomi.sdk.*
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
    val client = AntdClient.createRest()
    val result = client.dataPutPublic("Hello, Autonomi!".toByteArray())
    println(result.address)

    val data = client.dataGetPublic(result.address)
    println(String(data))
    client.close()
}
```

## Type mappings

| Autonomi type  | Kotlin type       |
| -------------- | ----------------- |
| `HealthStatus` | Kotlin data class |
| `PutResult`    | Kotlin data class |
| Raw data       | `ByteArray`       |

## Error handling

```kotlin
try {
    val data = client.dataGetPublic("nonexistent")
} catch (e: NotFoundException) {
    println("Not found")
} catch (e: PaymentException) {
    println("Payment required")
} catch (e: AntdException) {
    println(e.message)
}
```

## Full API reference

For all available daemon endpoints, see the [REST API](/developers/sdk/install/reference/rest-api.md).
