Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.xquik.com/llms.txt

Use this file to discover all available pages before exploring further.

Use the Java SDK for generated JVM models, builders, sync calls, async calls, and typed exceptions in Java 8+ applications.

Install

implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.3.0")

Authenticate

export X_TWITTER_SCRAPER_API_KEY="xq_YOUR_KEY_HERE"
XTwitterScraperOkHttpClient.fromEnv() reads X_TWITTER_SCRAPER_API_KEY, X_TWITTER_SCRAPER_BEARER_TOKEN, and X_TWITTER_SCRAPER_BASE_URL.

Basic Example

import com.x_twitter_scraper.api.client.XTwitterScraperClient;
import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient;
import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams;

XTwitterScraperClient client = XTwitterScraperOkHttpClient.fromEnv();

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

PaginatedTweets tweets = client.x().tweets().search(params);

Error Handling

The Java SDK throws unchecked exceptions.
StatusException
400BadRequestException
401UnauthorizedException
403PermissionDeniedException
404NotFoundException
422UnprocessableEntityException
429RateLimitException
5xxInternalServerException
Connection and I/O failures use XTwitterScraperIoException. All SDK exceptions inherit from XTwitterScraperException.

Pagination

Paginated responses expose generated fields such as hasNextPage. Use the endpoint cursor fields documented in the API reference when requesting additional pages.
if (tweets.hasNextPage()) {
    System.err.println("More results are available");
}

Webhooks & References