Skip to content

livekit/server-sdk-kotlin

Folders and files

NameName
Last commit message
Last commit date
May 9, 2025
Mar 13, 2025
Feb 22, 2025
Feb 22, 2025
May 9, 2025
Aug 29, 2024
May 9, 2025
Jan 9, 2024
Apr 4, 2025
Apr 15, 2023
Mar 13, 2025
Mar 12, 2025
Oct 14, 2022
Jan 9, 2024
Jan 13, 2024
Mar 13, 2025
Oct 8, 2024
Feb 22, 2025
Mar 13, 2025
Feb 22, 2025
Feb 22, 2025
Jan 9, 2024
Mar 13, 2025
Aug 20, 2024
Oct 6, 2022

Repository files navigation

The LiveKit icon, the name of the repository and some sample code in the background.

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.

Maven

<dependencies>
    <dependency>
        <groupId>io.livekit</groupId>
        <artifactId>livekit-server</artifactId>
        <version>0.9.0</version>
    </dependency>
</dependencies>

Gradle

dependencies {
    implementation 'io.livekit:livekit-server:0.9.0'
}

Usage

Server API Access

Obtain a RoomServiceClient or EgressServiceClient through their respective create methods, and then run calls through the client.

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<LivekitModels.Room> call = client.createRoom("room_name");
    Response<LivekitModels.Room> 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 for other async constructs such as CompletableFuture and RxJava.

Creating Access Tokens

Access tokens can be generated through the io.livekit.server.AccessToken class.

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)
Server APIsNode.js · Golang · Ruby · Java/Kotlin · Python · Rust · PHP (community) · .NET (community)
UI ComponentsReact · Android Compose · SwiftUI
Agents FrameworksPython · Node.js · Playground
ServicesLiveKit server · Egress · Ingress · SIP
ResourcesDocs · Example apps · Cloud · Self-hosting · CLI