Skip to content
Twexapi
English
Esc
↑↓navigate↵open⌘Jpreview
On this page

Kotlin SDK

Use the TwexAPI Kotlin SDK for tweet search, follower exports, and public reads with coroutine-friendly calls.

Use the Kotlin SDK when you want idiomatic Kotlin builders, nullable types, and coroutine await() over the generated Java client for TwexAPI REST workflows.

twexapi-dev/x-api-scraper-kotlinKotlin SDK for TwexAPI public social data and approved account workflows. Independent third-party service.00
Kotlin task SDK call Save
Search tweets sdk.search().advanced() nextCursor
Read profile sdk.users().getAbout() screenName
List followers sdk.users().followers().list() cursor

Install

Gradle:

implementation("io.twexapi:x-api-scraper-kotlin:0.1.0")

Maven:

<dependency>
    <groupId>io.twexapi</groupId>
    <artifactId>x-api-scraper-kotlin</artifactId>
    <version>0.1.0</version>
</dependency>

Maven Central may still be catching up. Install from source:

./gradlew publishToMavenLocal

Source: twexapi-dev/x-api-scraper-kotlin

Authenticate

export X_API_SCRAPER_KEY="YOUR_API_KEY"
import io.twexapi.sdk.kotlin.xapiScraper
import io.twexapi.sdk.models.components.AdvancedSearchCursorQuery

fun main() {
    val sdk = xapiScraper()

    val req = AdvancedSearchCursorQuery.builder()
        .searchTerms(listOf("from:elonmusk"))
        .sortBy("Latest")
        .nextCursor("")
        .build()

    val res = sdk.search().advanced().request(req).call()
    println(res)
}

Use coroutines

async() returns the Java CompletableFuture client. Call await() from a coroutine:

import io.twexapi.sdk.kotlin.async
import io.twexapi.sdk.kotlin.await
import io.twexapi.sdk.kotlin.xapiScraper
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
    val sdk = xapiScraper().async()

    val req = AdvancedSearchCursorQuery.builder()
        .searchTerms(listOf("from:elonmusk"))
        .sortBy("Latest")
        .nextCursor("")
        .build()

    val res = sdk.search().advanced().request(req).call().await()
    println(res)
}

References

Was this page helpful?