All integrations
Kotlin + ParseAPI

Kotlin. Make your first call.

Install the official Kotlin client and bring ParseAPI into your app.

Official Kotlin SDK

Kotlin install
git clone --branch 1.8.0 --depth 1 https://github.com/parseapi/kotlin.git ../parseapi-kotlin

Your language. The same ParseAPI.

Get connected

One country. Your first request.

Look up the United States and print its name.

01

Install the library.

Import your app module's BuildConfig when this file is in a different package. The app ID must match the key's allowed package name.

Terminal
git clone --branch 1.8.0 --depth 1 https://github.com/parseapi/kotlin.git ../parseapi-kotlin
settings.gradle.kts
includeBuild("../parseapi-kotlin")
build.gradle.kts
dependencies {
    implementation("com.parseapi:parseapi:1.8.0")
}
02

Add your app key.

Create an app key in Keys and allow your application ID. Replace parse_app_... in the example.

Set appId to your application ID, as shown below. Carrier, HLR and Email mailbox verification require a secret key on your server.

03

Make a request.

Add this function to your app, then call it from a coroutine. This lookup uses your plan's request allowance.

Kotlin app code
import com.parseapi.ParseAPI

suspend fun loadCountry() {
    val parse = ParseAPI("parse_app_...") {
        appId = BuildConfig.APPLICATION_ID
    }
    val country = parse.country("US")
    println(country.name)
}

// Call loadCountry() from your app's coroutine.
Expected outputUnited States
Handle API errors

Read the error code and request ID when an API request fails. Branch on the code, such as not_found, rather than the message. A response with valid: false is a successful lookup. Transport failures still propagate.

Kotlin app code with error handling
import com.parseapi.ParseAPI
import com.parseapi.ParseAPIException

suspend fun loadCountry() {
    val parse = ParseAPI("parse_app_...") {
        appId = BuildConfig.APPLICATION_ID
    }
    try {
        val country = parse.country("US")
        println(country.name)
    } catch (error: ParseAPIException) {
        println("${error.code} ${error.status} ${error.requestId}")
        throw error
    }
}

// Call loadCountry() from your app's coroutine.
Requests and retries

SDK methods follow the API routes. Unknown response values stay unknown, rather than becoming empty strings or guesses.

Ordinary lookups retry temporary failures. Separately metered checks make one attempt by default. You can configure the retry count. See the retry policy.

Build with a working example