22
33<!-- x-release-please-start-version -->
44
5- [ ![ Maven Central] ( https://img.shields.io/maven-central/v/com.x_twitter_scraper.api/x-twitter-scraper-java )] ( https://central.sonatype.com/artifact/com.x_twitter_scraper.api/x-twitter-scraper-java/0.1 .0 )
6- [ ![ javadoc] ( https://javadoc.io/badge2/com.x_twitter_scraper.api/x-twitter-scraper-java/0.1 .0/javadoc.svg )] ( https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.1 .0 )
5+ [ ![ Maven Central] ( https://img.shields.io/maven-central/v/com.x_twitter_scraper.api/x-twitter-scraper-java )] ( https://central.sonatype.com/artifact/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2 .0 )
6+ [ ![ javadoc] ( https://javadoc.io/badge2/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2 .0/javadoc.svg )] ( https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2 .0 )
77
88<!-- x-release-please-end -->
99
1010The X Twitter Scraper Java SDK provides convenient access to the [ X Twitter Scraper REST API] ( https://xquik.com ) from applications written in Java.
1111
12+ The X Twitter Scraper Java SDK is similar to the X Twitter Scraper Kotlin SDK but with minor differences that make it more ergonomic for use in Java, such as ` Optional ` instead of nullable values, ` Stream ` instead of ` Sequence ` , and ` CompletableFuture ` instead of suspend functions.
13+
1214It is generated with [ Stainless] ( https://www.stainless.com/ ) .
1315
1416<!-- x-release-please-start-version -->
1517
16- The REST API documentation can be found on [ xquik.com] ( https://xquik.com ) . Javadocs are available on [ javadoc.io] ( https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.1 .0 ) .
18+ The REST API documentation can be found on [ xquik.com] ( https://xquik.com ) . Javadocs are available on [ javadoc.io] ( https://javadoc.io/doc/com.x_twitter_scraper.api/x-twitter-scraper-java/0.2 .0 ) .
1719
1820<!-- x-release-please-end -->
1921
@@ -24,7 +26,7 @@ The REST API documentation can be found on [xquik.com](https://xquik.com). Javad
2426### Gradle
2527
2628``` kotlin
27- implementation(" com.x_twitter_scraper.api:x-twitter-scraper-java:0.1 .0" )
29+ implementation(" com.x_twitter_scraper.api:x-twitter-scraper-java:0.2 .0" )
2830```
2931
3032### Maven
@@ -33,7 +35,7 @@ implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.1.0")
3335<dependency >
3436 <groupId >com.x_twitter_scraper.api</groupId >
3537 <artifactId >x-twitter-scraper-java</artifactId >
36- <version >0.1 .0</version >
38+ <version >0.2 .0</version >
3739</dependency >
3840```
3941
@@ -48,8 +50,8 @@ This library requires Java 8 or later.
4850``` java
4951import com.x_twitter_scraper.api.client.XTwitterScraperClient ;
5052import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient ;
51- import com.x_twitter_scraper.api.models.PaginatedTweets ;
5253import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams ;
54+ import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse ;
5355
5456// Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties
5557// Or configures using the `X_TWITTER_SCRAPER_API_KEY`, `X_TWITTER_SCRAPER_BEARER_TOKEN` and `X_TWITTER_SCRAPER_BASE_URL` environment variables
@@ -59,7 +61,7 @@ TweetSearchParams params = TweetSearchParams.builder()
5961 .q(" from:elonmusk" )
6062 .limit(10L )
6163 .build();
62- PaginatedTweets paginatedTweets = client. x(). tweets(). search(params);
64+ TweetSearchResponse response = client. x(). tweets(). search(params);
6365```
6466
6567## Client configuration
@@ -134,7 +136,7 @@ The `withOptions()` method does not affect the original client or service.
134136
135137To send a request to the X Twitter Scraper API, build an instance of some ` Params ` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.
136138
137- For example, ` client.x().tweets().search(...) ` should be called with an instance of ` TweetSearchParams ` , and it will return an instance of ` PaginatedTweets ` .
139+ For example, ` client.x().tweets().search(...) ` should be called with an instance of ` TweetSearchParams ` , and it will return an instance of ` TweetSearchResponse ` .
138140
139141## Immutability
140142
@@ -151,8 +153,8 @@ The default client is synchronous. To switch to asynchronous execution, call the
151153``` java
152154import com.x_twitter_scraper.api.client.XTwitterScraperClient ;
153155import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClient ;
154- import com.x_twitter_scraper.api.models.PaginatedTweets ;
155156import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams ;
157+ import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse ;
156158import java.util.concurrent.CompletableFuture ;
157159
158160// Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties
@@ -163,16 +165,16 @@ TweetSearchParams params = TweetSearchParams.builder()
163165 .q(" from:elonmusk" )
164166 .limit(10L )
165167 .build();
166- CompletableFuture<PaginatedTweets > paginatedTweets = client. async(). x(). tweets(). search(params);
168+ CompletableFuture<TweetSearchResponse > response = client. async(). x(). tweets(). search(params);
167169```
168170
169171Or create an asynchronous client from the beginning:
170172
171173``` java
172174import com.x_twitter_scraper.api.client.XTwitterScraperClientAsync ;
173175import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync ;
174- import com.x_twitter_scraper.api.models.PaginatedTweets ;
175176import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams ;
177+ import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse ;
176178import java.util.concurrent.CompletableFuture ;
177179
178180// Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties
@@ -183,7 +185,7 @@ TweetSearchParams params = TweetSearchParams.builder()
183185 .q(" from:elonmusk" )
184186 .limit(10L )
185187 .build();
186- CompletableFuture<PaginatedTweets > paginatedTweets = client. x(). tweets(). search(params);
188+ CompletableFuture<TweetSearchResponse > response = client. x(). tweets(). search(params);
187189```
188190
189191The asynchronous client supports the same options as the synchronous one, except most methods return ` CompletableFuture ` s.
@@ -309,25 +311,25 @@ To access this data, prefix any HTTP method call on a client or service with `wi
309311``` java
310312import com.x_twitter_scraper.api.core.http.Headers ;
311313import com.x_twitter_scraper.api.core.http.HttpResponseFor ;
312- import com.x_twitter_scraper.api.models.PaginatedTweets ;
313314import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams ;
315+ import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse ;
314316
315317TweetSearchParams params = TweetSearchParams . builder()
316318 .q(" from:elonmusk" )
317319 .limit(10L )
318320 .build();
319- HttpResponseFor<PaginatedTweets > paginatedTweets = client. x(). tweets(). withRawResponse(). search(params);
321+ HttpResponseFor<TweetSearchResponse > response = client. x(). tweets(). withRawResponse(). search(params);
320322
321- int statusCode = paginatedTweets . statusCode();
322- Headers headers = paginatedTweets . headers();
323+ int statusCode = response . statusCode();
324+ Headers headers = response . headers();
323325```
324326
325327You can still deserialize the response into an instance of a Java class if needed:
326328
327329``` java
328- import com.x_twitter_scraper.api.models.PaginatedTweets ;
330+ import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse ;
329331
330- PaginatedTweets parsedPaginatedTweets = paginatedTweets . parse();
332+ TweetSearchResponse parsedResponse = response . parse();
331333```
332334
333335## Error handling
@@ -425,9 +427,9 @@ Requests time out after 1 minute by default.
425427To set a custom timeout, configure the method call using the ` timeout ` method:
426428
427429``` java
428- import com.x_twitter_scraper.api.models.PaginatedTweets ;
430+ import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse ;
429431
430- PaginatedTweets paginatedTweets = client. x(). tweets(). search(
432+ TweetSearchResponse response = client. x(). tweets(). search(
431433 params, RequestOptions . builder(). timeout(Duration . ofSeconds(30 )). build()
432434);
433435```
@@ -703,17 +705,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`XT
703705If you would prefer to check that the response is completely well-typed upfront, then either call ` validate() ` :
704706
705707``` java
706- import com.x_twitter_scraper.api.models.PaginatedTweets ;
708+ import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse ;
707709
708- PaginatedTweets paginatedTweets = client. x(). tweets(). search(params). validate();
710+ TweetSearchResponse response = client. x(). tweets(). search(params). validate();
709711```
710712
711713Or configure the method call to validate the response using the ` responseValidation ` method:
712714
713715``` java
714- import com.x_twitter_scraper.api.models.PaginatedTweets ;
716+ import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse ;
715717
716- PaginatedTweets paginatedTweets = client. x(). tweets(). search(
718+ TweetSearchResponse response = client. x(). tweets(). search(
717719 params, RequestOptions . builder(). responseValidation(true ). build()
718720);
719721```
0 commit comments