Skip to main content

Java/Kotlin Server SDK

Client vs. Server

These docs are for using the java SDK in a multi-user, server side context. For client-side android applicaitons, try our android sdk. For non-android java or kotlin client side applications, feel free to request an sdk.

This SDK is written in Kotlin, but exposes methods and overrides to Java based applications. It is open source and hosted on github.

The Basics#

Get started in a few quick steps.

  1. Create a free account on statsig.com
  2. Install the SDK
  3. Initialize and use the SDK

Step 1 - Create a free account on www.statsig.com#

You could skip this for now, but you will need an SDK Key and some Feature Gates or Dynamic Configs to use with the SDK in just a minute.

Step 2 - Install the SDK#

Install the sdk using jitpack

https://jitpack.io/#statsig-io/java-server-sdk

Step 3 - Initialize and use the SDK#

Initialize the SDK using a Server Secret Key from the statsig console:

Future initFuture = StatsigServer.initializeAsync("<server_secret>");
initFuture.get();
// Now you can check gates, get configs, log events
StatsigUser user = new StatsigUser();
user.email = "address@domain.com"
Future<Boolean> featureOn = StatsigServer.checkGateAsync(user, "<gate_name>");
Boolean isFeatureOn = featureOn.get()
Asynchronous APIs

Most SDK APIs run synchronously, so why are getConfig and checkGate asynchronous?

The main reason is that older versions of the SDK might not know how to interpret new types of gate conditions. In such cases the SDK will make an asynchronous call to our servers to fetch the result of a check. This can be resolved by upgrading the SDK, and we will warn you if this happens.

For more details, read our blog post about SDK evaluations. If you have any questions, please ask them in our Feedback Repository.

More Information#

For more information, see our SDK documentation on github.