---
url: https://talkjs.com/docs/Data_APIs/Kotlin/
title: "Kotlin Data API | TalkJS Docs"
---

For AI agents: Find a documentation index at https://talkjs.com/llms.txt (full content at https://talkjs.com/llms-full.txt). Get a markdown version of any page by appending .md to its URL path.

# Kotlin Data API

Connect to chat data as a user.

The Kotlin Data API lets you connect to TalkJS as a user and read, subscribe to, and update chat data from Kotlin-based environments. It's available through the TalkJS Core (`com.talkjs:core`) package on [Maven Central](https://central.sonatype.com/artifact/com.talkjs/core).

The Data API is primarily intended for client environments such as Android apps, because it connects as a single specific user.

If you need server-side access to all conversations or users, use the [REST API](https://talkjs.com/docs/REST_API/) instead.

## Multi-platform support

The Kotlin Data API is multi-platform, with support for Android and JVM environments. For iOS and macOS apps, use the [Swift Data API](https://talkjs.com/docs/Data_APIs/Swift/), which shares the same core.

## Requirements

To use the Kotlin Data API, your project needs to have the following:

-   Kotlin 2.0+
-   For Android apps: Android API 24+
-   For JVM environments: Java 11+

## Installation

To add the TalkJS Core package to your project, include the following in your `build.gradle.kts` file:

```kotlin
dependencies {
  implementation("com.talkjs:core:<latest_version>")
}
```

Replace `<latest_version>` with the latest available version, for example `0.1.0`. You can check Maven Central for the [latest version](https://central.sonatype.com/artifact/com.talkjs/core).

## Create a TalkJS session

The Kotlin Data API is available under the `com.talkjs.core` package namespace.

To connect as a user, create a TalkJS session using [getTalkSession](https://talkjs.com/docs/Data_APIs/Kotlin/TalkSession/):

```kotlin
import com.talkjs.core.getTalkSession

val session = getTalkSession(
	appId = "<APP_ID>", // Replace with your own app ID
	userId = "<USER_ID>", // Replace with a user ID
)
```

Replace:

-   `<APP_ID>` with your TalkJS app ID. You can find your app ID on the **Settings** page of your [TalkJS dashboard](https://talkjs.com/dashboard/).
-   `<USER_ID>` with the [ID of the user](https://talkjs.com/docs/Concepts/Users/#user-id) you want to connect as.

Once connected, the session allows you to retrieve conversations, send messages, and subscribe to real-time updates.

## Android permissions

To use TalkJS in your app, it must have permission to access the internet. In your `AndroidManifest.xml` file, make sure the following line is present:

```xml
<uses-permission android:name="android.permission.INTERNET" />
```

This is required for TalkJS to connect to the TalkJS servers.
