Skip to content

stadiamaps/stadiamaps-api-kotlin

Repository files navigation

Stadia Maps Kotlin SDK

This SDK helps you access the full range of geospatial APIs from Stadia Maps using Kotlin and other JVM languages. We've derived everything from our official API spec, so you'll get all the goodies like autocomplete, model definitions, and other documentation in your favorite editor.

This package specifically targets Kotlin and retrofit2. If you'd prefer to customize the generated code to your stack (ex: using okhttp), we've written a tutorial on generating code within JVM projects over here.

Getting started with Gradle

Add Maven Central to your build script

Add the following to your build script (build.gradle.kts or build.gradle):

repositories {
    mavenCentral()
}

Add dependencies

Now you're ready to add the package and its dependencies.

Kotlin:

dependencies {
    val retrofitVersion = "2.11.0"
    
    // API package
    implementation("com.stadiamaps:api:3.2.1")

    // Dependencies
    implementation("com.squareup.moshi:moshi-kotlin:1.15.1")
    implementation("com.squareup.moshi:moshi-adapters:1.15.1")
    implementation("com.squareup.okhttp3:logging-interceptor:4.10.0")
    implementation("com.squareup.retrofit2:retrofit:$retrofitVersion")
    implementation("com.squareup.retrofit2:converter-moshi:$retrofitVersion")
    implementation("com.squareup.retrofit2:converter-scalars:$retrofitVersion")
}

Groovy:

dependencies {
    def retrofitVersion = "2.11.0"
    
    // API package
    implementation 'com.stadiamaps:api:3.2.1'

    // Dependencies
    implementation 'com.squareup.moshi:moshi-kotlin:1.15.1'
    implementation 'com.squareup.moshi:moshi-adapters:1.15.1'
    implementation 'com.squareup.okhttp3:logging-interceptor:4.10.0'
    implementation "com.squareup.retrofit2:retrofit:${retrofitVersion}"
    implementation "com.squareup.retrofit2:converter-moshi:${retrofitVersion}"
    implementation "com.squareup.retrofit2:converter-scalars:${retrofitVersion}"
}

Usage

Next, you'll need a Stadia Maps API key. You can create an API key for free here (no credit card required).

See the example app for usage examples.

Documentation

Official documentation lives at docs.stadiamaps.com, where we have both long-form prose explanations of each endpoint and an interactive API reference. If you're using an IDE like IntelliJ though, the auto-complete and built-in documentation functionality is even easier to use than the online generated reference.