SDKsIngest

Kotlin SDK (ingest)

Quickly integrate the Ours Privacy Kotlin SDK using Gradle or Maven. Explore its features with our Interactive API Explorer.

Ours Privacy Kotlin SDK Documentation

This is a quick start guide for integrating the Ours Privacy Kotlin SDK into your server-side applications.

Installation

Gradle

Add the following to your build.gradle.kts:

dependencies {
    implementation("com.oursprivacy:ours-privacy-kotlin")
}

Maven

Add the following to your pom.xml:

<dependency>
    <groupId>com.oursprivacy</groupId>
    <artifactId>ours-privacy-kotlin</artifactId>
</dependency>

For more details, visit the Maven Central | Github Repo.

Requirements

This library requires Java 8 or later.

Usage

Initialize the client and send events with just a few lines of code:

import com.oursprivacy.client.OursPrivacyClient
import com.oursprivacy.client.okhttp.OursPrivacyOkHttpClient
import com.oursprivacy.models.track.TrackEventParams

// Configures using the OURS_PRIVACY_BASE_URL environment variable
val client: OursPrivacyClient = OursPrivacyOkHttpClient.fromEnv()

// Track an event
val params: TrackEventParams = TrackEventParams.builder()
    .token("your-api-key")
    .event("Purchase")
    .build()
val response = client.track().event(params)

Configuration

Configure the client using environment variables:

Environment variableRequiredDefault value
OURS_PRIVACY_BASE_URLtruehttps://api.oursprivacy.com/api/v1

Or configure manually:

val client = OursPrivacyOkHttpClient.builder()
    .baseUrl("https://api.oursprivacy.com/api/v1")
    .build()

Explore the API

Want to see what the SDK can do? Try our Interactive API Explorer to experiment with endpoints and features in real time.

How is this guide?

On this page