SDK quickstart: Kotlin (Android)
Generate a typed Kotlin client for the /v1 Developer API from its OpenAPI spec
and make your first call.
No hand-written Kotlin SDK is published yet — you generate one from the live spec. An official SDK is a roadmap item.
Which credential? A shared API key (
sk_live_…) suits your own automation and server-side jobs. A first-party Android app a user logs into should authenticate as that user with OAuth 2.0 + PKCE and send the user's token — see Build a client. The steps below use an API key; swap in the user's bearer token for a logged-in app.
1. Get the spec
https://api-dev.traxstreaming.live/v1/openapi.json
2. Generate a typed client
Use openapi-generator with the
kotlin generator (Retrofit2 + coroutines is a good default for Android):
npm i -g @openapitools/openapi-generator-cli
openapi-generator-cli generate \
-i https://api-dev.traxstreaming.live/v1/openapi.json \
-g kotlin \
--additional-properties=library=jvm-retrofit2,useCoroutines=true,packageName=live.traxstreaming.api \
-o ./trax-client-kotlin
Add the generated module to your Gradle build (include(":trax-client-kotlin")
in settings.gradle, then depend on it from your app module).
3. Authenticate
Create an API key from your account's Developer / API Keys screen and copy
the sk_live_… secret once. Store it with EncryptedSharedPreferences or the
Android Keystore — never hardcoded in the APK or in strings.xml. For a
user-login app, store the user's OAuth access token securely instead.
4. First call
Add the bearer token with an OkHttp interceptor, then call the generated API:
import live.traxstreaming.api.apis.StudiosApi
import okhttp3.OkHttpClient
import retrofit2.Retrofit
import retrofit2.converter.moshi.MoshiConverterFactory
val http = OkHttpClient.Builder()
.addInterceptor { chain ->
val req = chain.request().newBuilder()
.header("Authorization", "Bearer $apiKey") // or the user's OAuth token
.build()
chain.proceed(req)
}
.build()
val retrofit = Retrofit.Builder()
.baseUrl("https://api-dev.traxstreaming.live/")
.client(http)
.addConverterFactory(MoshiConverterFactory.create())
.build()
val studios = retrofit.create(StudiosApi::class.java)
// List your studios (requires the studios:read scope)
val page = studios.listStudios(limit = 50) // suspend fun (coroutines)
page.data.forEach { println("${it.id} ${it.name}") }
page.nextCursor?.let { cursor ->
// pass `cursor` to fetch the next page — see /reference/pagination
}
Generated method and model names (listStudios, StudiosApi, nextCursor)
come from the spec's operationIds and schemas, matching the
API reference. On a non-2xx response, decode the error body
— it's the one envelope { error: { code, message, requestId } }.
Next
- Errors — branch on
error.code; retry only transient codes. - Pagination · Rate limits.
- Build a client — OAuth (PKCE) login, WebSocket control, and WebRTC (WHIP/WHEP) media for a full producing app on Android.