Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

X (Twitter) Scraper Kotlin SDK: Tweet Search, Timelines, Followers & Posting

CI OpenSSF Best Practices

Use Xquik's typed Kotlin client for X data and confirmed actions.

It supports tweet search, timeline extraction, follower exports, monitoring, and posting.

Use it as a typed X API or Twitter API alternative.

API reference · Authentication · KDocs

Maven Central KDocs

Choose the Kotlin SDK

Choose this client for Kotlin services using coroutines and typed builders. Suspending methods integrate with structured concurrency. Choose the Java SDK for Java-first codebases.

Common X Data Tasks

These questions map customer language to exact routes and Kotlin services.

Customer Question REST Route Kotlin Service
How do I search tweets without the X API? GET /x/tweets/search client.x().tweets()
How do I retrieve tweets, threads, replies, or quotes? GET /x/tweets/{id}, GET /x/tweets/{id}/thread client.x().tweets()
How do I search X or Twitter users? GET /x/users/search client.x().users()
How do I scrape an X profile timeline? GET /x/users/{id}/tweets client.x().users()
How do I export X followers? GET /x/users/{id}/followers client.x().users()
How do I export X following accounts? GET /x/users/{id}/following client.x().users()
How do I collect verified followers? GET /x/users/{id}/verified-followers client.x().users()
How do I collect mentions, likes, replies, or media? GET /x/users/{id}/mentions, GET /x/users/{id}/likes client.x().users()
How do I extract my X home timeline? GET /x/timeline client.x()
How do I extract list tweets, members, or followers? GET /x/lists/{id}/tweets, GET /x/lists/{id}/members client.x().lists()
How do I search communities and collect their tweets? GET /x/communities/search, GET /x/communities/{id}/tweets client.x().communities()
How do I read bookmarks and bookmark folders? GET /x/bookmarks, GET /x/bookmarks/folders client.x().bookmarks()
How do I read notifications or direct messages? GET /x/notifications, GET /x/dm/{userId}/history client.x(), client.x().dm()
How do I discover X trends? GET /x/trends client.x().getTrends()
How do I export large X datasets? POST /extractions client.extractions()
How do I monitor tweet keywords or accounts? POST /monitors/keywords, POST /monitors client.monitors()
How do I receive signed event deliveries? POST /webhooks client.webhooks()
How do I post, like, retweet, or follow? POST /x/tweets, POST /x/users/{id}/follow client.x().tweets(), client.x().users()
How do I send media or update a profile? POST /x/media, PATCH /x/profile client.x().media(), client.x().profile()
How do I manage connected X accounts? GET /x/accounts, POST /x/accounts client.x().accounts()

Use KDocs for typed methods.

Use API reference for request contracts.

Install

Gradle:

implementation("com.xquik.api:x-twitter-scraper-kotlin:0.9.0")

Maven:

<dependency>
  <groupId>com.xquik.api</groupId>
  <artifactId>x-twitter-scraper-kotlin</artifactId>
  <version>0.9.0</version>
</dependency>

Verify Maven Signatures

Every Maven Central file has a detached OpenPGP signature.

Verify the main Kotlin artifact:

artifact="x-twitter-scraper-kotlin-0.5.2.jar"
base="https://repo.maven.apache.org/maven2/com/xquik/api/x-twitter-scraper-kotlin/0.5.2"
curl --fail --location --remote-name "$base/$artifact"
curl --fail --location --remote-name "$base/$artifact.asc"
gpg --keyserver hkps://keyserver.ubuntu.com --recv-keys 0xD2037E4157E62A59
gpg --verify "$artifact.asc" "$artifact"

Confirm fingerprint 6965 E561 C0AC EE32 060A B961 D203 7E41 57E6 2A59.

Authenticate

Create an API key in the Xquik dashboard. Then set:

export X_TWITTER_SCRAPER_API_KEY="your-api-key"

OAuth users can set X_TWITTER_SCRAPER_BEARER_TOKEN instead.

Create 1 client and reuse it:

import com.x_twitter_scraper.api.client.XTwitterScraperClient
import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient

val client: XTwitterScraperClient = XTwitterScraperOkHttpClient.fromEnv()

You can also pass credentials directly:

val client: XTwitterScraperClient = XTwitterScraperOkHttpClient.builder()
    .apiKey("your-api-key")
    .build()

Supported client settings:

Setting System Property Environment Variable Default
API key xtwitterscraper.apiKey X_TWITTER_SCRAPER_API_KEY None
OAuth token xtwitterscraper.bearerToken X_TWITTER_SCRAPER_BEARER_TOKEN None
Base URL xtwitterscraper.baseUrl X_TWITTER_SCRAPER_BASE_URL https://xquik.com/api/v1

System properties override environment variables.

Search Posts

import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse

val params = TweetSearchParams.builder()
    .q("from:elonmusk")
    .limit(10L)
    .build()

val result: TweetSearchResponse = client.x().tweets().search(params)

Close the client when your application stops:

client.close()

Use Coroutines

Call async() to use suspending methods:

val result: TweetSearchResponse = client.async().x().tweets().search(params)

Configure Retries

The client retries eligible failures twice by default.

val client: XTwitterScraperClient = XTwitterScraperOkHttpClient.builder()
    .fromEnv()
    .maxRetries(4)
    .build()

Xquik may still return a successful HTTP response with a structured API error. Handle the documented error code from the response body.

Read Raw Responses

Use withRawResponse() when you need headers or status codes:

import com.x_twitter_scraper.api.core.http.HttpResponseFor
import com.x_twitter_scraper.api.models.account.AccountRetrieveResponse

val response: HttpResponseFor<AccountRetrieveResponse> =
    client.account().withRawResponse().retrieve()

val status: Int = response.statusCode()
val account: AccountRetrieveResponse = response.parse()

Binary endpoints return HttpResponse. Close each response after reading it.

Support

License

Apache License 2.0

Xquik is an independent third-party service. Not affiliated with X Corp. "Twitter" and "X" are trademarks of X Corp.

Releases

Packages

Contributors

Languages