> For the complete documentation index, see [llms.txt](https://docs.winga.me/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.winga.me/integrations/kotlin.md).

# Kotlin

There is no dedicated Winga SDK for Kotlin. Use the [Evaluation API](/api-reference/evaluation-api.md) directly with Ktor's HTTP client. Load the flag map once, then read it.

```kotlin
import io.ktor.client.HttpClient
import io.ktor.client.call.body
import io.ktor.client.request.get
import io.ktor.client.request.header
import kotlinx.serialization.Serializable

@Serializable
data class FlagState(val enabled: Boolean)

@Serializable
data class FlagsResponse(val flags: Map<String, FlagState>)

class WingaClient(private val apiKey: String, private val environment: String) {
    private val http = HttpClient()
    private var flags: Map<String, FlagState> = emptyMap()

    suspend fun load() {
        val response: FlagsResponse =
            http.get("https://api.winga.me/v1/flags?env=$environment") {
                header("X-Winga-Key", apiKey)
            }.body()
        flags = response.flags
    }

    fun isEnabled(key: String): Boolean = flags[key]?.enabled ?: false
}
```

```kotlin
// Usage
val ff = WingaClient("proj_live_xxx", "production")
ff.load()

if (ff.isEnabled("new-checkout")) {
    // ...
}
```

For realtime updates, stream `GET /v1/stream?env=<environment>` and re-decode the flag map on each `data:` frame.
