https://github.com/livekit/server-sdk-kotlin
https://github.com/livekit/server-sdk-kotlin
Last synced: 11 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/livekit/server-sdk-kotlin
- Owner: livekit
- License: apache-2.0
- Created: 2022-10-06T14:53:47.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-07-21T18:18:54.000Z (11 months ago)
- Last Synced: 2025-07-21T20:24:54.212Z (11 months ago)
- Language: Kotlin
- Size: 1.44 MB
- Stars: 50
- Watchers: 17
- Forks: 27
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README

# LiveKit Server SDK for Kotlin
Use this SDK to interact with LiveKit server APIs and create access tokens from your Kotlin backend.
## Installation
This SDK is available as a Maven package through [Maven Central](https://search.maven.org/search?q=g:io.livekit%20a:livekit-server).
### Maven
```xml title="pom.xml"
io.livekit
livekit-server
0.10.0
```
### Gradle
```groovy title="build.gradle"
dependencies {
implementation 'io.livekit:livekit-server:0.10.0'
}
```
## Usage
### Server API Access
Obtain a `RoomServiceClient` or `EgressServiceClient` through their respective `create` methods, and then run calls through the client.
```java
package org.example;
import com.google.protobuf.util.JsonFormat;
import java.io.IOException;
import io.livekit.server.RoomServiceClient;
import livekit.LivekitModels;
import retrofit2.Call;
import retrofit2.Response;
public class Main {
public static void main(String[] args) throws IOException {
RoomServiceClient client = RoomServiceClient.createClient(
"http://example.com",
"apiKey",
"secret");
Call call = client.createRoom("room_name");
Response response = call.execute(); // Use call.enqueue for async
LivekitModels.Room room = response.body();
System.out.println(JsonFormat.printer().print(room));
}
}
```
`Call` adapters are also available through [Retrofit](https://github.com/square/retrofit/tree/master/retrofit-adapters) for other async constructs such as `CompletableFuture` and RxJava.
### Creating Access Tokens
Access tokens can be generated through the `io.livekit.server.AccessToken` class.
```java
AccessToken token = new AccessToken("apiKey", "secret");
// Fill in token information.
token.setName("name");
token.setIdentity("identity");
token.setMetadata("metadata");
token.addGrants(new RoomJoin(true), new RoomName("myroom"));
// Sign and create token string.
System.out.println("New access token: " + token.toJwt())
```
By default, tokens expire 6 hours after generation. You may override this by using `token.setTtl(long millis)`.
LiveKit Ecosystem
LiveKit SDKsBrowser · iOS/macOS/visionOS · Android · Flutter · React Native · Rust · Node.js · Python · Unity · Unity (WebGL) · ESP32
Server APIsNode.js · Golang · Ruby · Java/Kotlin · Python · Rust · PHP (community) · .NET (community)
UI ComponentsReact · Android Compose · SwiftUI · Flutter
Agents FrameworksPython · Node.js · Playground
ServicesLiveKit server · Egress · Ingress · SIP
ResourcesDocs · Example apps · Cloud · Self-hosting · CLI