Skip to content

Latest commit

 

History

104 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Xquik Java SDK: Twitter Search, Followers & X Automation

CI OpenSSF Best Practices

Search Twitter, read timelines, fetch profiles & export followers with Xquik. Use typed Java methods for media, webhooks & X automation.

API Reference | Authentication | Javadocs

Maven Central Javadocs

Java Client

Use this SDK for Java services with builders and typed models. Use synchronous calls or client.async() for CompletableFuture pipelines.

Common Twitter & X Tasks

Task REST Route Java Service
Run an advanced Twitter search GET /x/tweets/search client.x().tweets()
Retrieve tweets, threads, replies, or quotes GET /x/tweets/{id}, GET /x/tweets/{id}/thread client.x().tweets()
Search X or Twitter users GET /x/users/search client.x().users()
Scrape an X profile timeline GET /x/users/{id}/tweets client.x().users()
Export X followers GET /x/users/{id}/followers client.x().users()
Export X following accounts GET /x/users/{id}/following client.x().users()
Collect verified followers GET /x/users/{id}/verified-followers client.x().users()
Collect mentions, likes, replies, or media GET /x/users/{id}/mentions, GET /x/users/{id}/likes client.x().users()
Extract an X home timeline GET /x/timeline client.x()
Extract list tweets, members, or followers GET /x/lists/{id}/tweets, GET /x/lists/{id}/members client.x().lists()
Search communities and collect their tweets GET /x/communities/search, GET /x/communities/{id}/tweets client.x().communities()
Read bookmarks and bookmark folders GET /x/bookmarks, GET /x/bookmarks/folders client.x().bookmarks()
Read notifications or direct messages GET /x/notifications, GET /x/dm/{userId}/history client.x(), client.x().dm()
Discover X trends GET /x/trends client.x().getTrends()
Export large X datasets POST /extractions client.extractions()
Monitor tweet keywords or accounts POST /monitors/keywords, POST /monitors client.monitors()
Receive signed event deliveries POST /webhooks client.webhooks()
Post, like, retweet, or follow POST /x/tweets, POST /x/users/{id}/follow client.x().tweets(), client.x().users()
Send media or update a profile POST /x/media, PATCH /x/profile client.x().media(), client.x().profile()
Manage connected X accounts GET /x/accounts, POST /x/accounts client.x().accounts()

Install

Gradle:

implementation("com.xquik.api:x-twitter-scraper-java:0.10.3")

Maven:

<dependency>
  <groupId>com.xquik.api</groupId>
  <artifactId>x-twitter-scraper-java</artifactId>
  <version>0.10.3</version>
</dependency>

Verify Maven Signatures

Every Maven Central file has a detached OpenPGP signature. Set VERSION, then verify the artifact:

version=VERSION
artifact="x-twitter-scraper-java-$version.jar"
base="https://repo.maven.apache.org/maven2/com/xquik/api/x-twitter-scraper-java/$version"
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 one client and reuse it:

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

XTwitterScraperClient client = XTwitterScraperOkHttpClient.fromEnv();

Pass credentials directly when needed:

XTwitterScraperClient client = 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 Tweets

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

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

TweetSearchResponse result = client.x().tweets().search(params);

Close the client when your application stops:

client.close();

Use Async Calls

Call async() to receive CompletableFuture results:

import java.util.concurrent.CompletableFuture;

CompletableFuture<TweetSearchResponse> result =
    client.async().x().tweets().search(params);

Configure Retries

The client retries eligible failures twice by default.

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

Successful HTTP responses can contain structured API errors. Handle documented codes.

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;

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

int status = response.statusCode();
AccountRetrieveResponse account = 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