Skip to main content

Dependencies

Before you can use the Player API, you need to add our dependencies to your project. Please refer to following guides, depending on your platform:

Initialization

After adding the dependencies, you can initialize the Player API.

Initialize with Default Configuration

If you are using the Player API in any platform, we automatically set the secret token with PLAYER_SECRET environment variable.
val playerApi = PlayerApi.createCoroutineApi()

Connect with Secret Token

val playerApi = PlayerApi.createCoroutineApi("your-secret-key")
You can find your secret in <installation-dir>/components/.secrets/auth.secret

Best Practices

  • Multiple Instances: Don’t create multiple instances of the Player API. While it’s possible to create multiple instances, we don’t recommend it. Just create a single instance and use it everywhere (preferred with dependency injection).
  • Asynchronous Operations: Use Coroutines for asynchronous operations in Kotlin, or CompletableFuture for Java. We don’t recommend using our API in sync operations.
  • Error Handling: We don’t throw any exceptions, we return null or Future objects. You should handle errors by yourself.