Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publish-sonatype.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
export -- GPG_SIGNING_KEY_ID
printenv -- GPG_SIGNING_KEY | gpg --batch --passphrase-fd 3 --import 3<<< "$GPG_SIGNING_PASSWORD"
GPG_SIGNING_KEY_ID="$(gpg --with-colons --list-keys | awk -F : -- '/^pub:/ { getline; print "0x" substr($10, length($10) - 7) }')"
./gradlew publish --no-configuration-cache
./gradlew publishAndReleaseToMavenCentral --stacktrace -PmavenCentralUsername="$SONATYPE_USERNAME" -PmavenCentralPassword="$SONATYPE_PASSWORD" --no-configuration-cache
env:
SONATYPE_USERNAME: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_USERNAME || secrets.SONATYPE_USERNAME }}
SONATYPE_PASSWORD: ${{ secrets.X_TWITTER_SCRAPER_SONATYPE_PASSWORD || secrets.SONATYPE_PASSWORD }}
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0"
".": "0.2.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 115
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-af60c455e2c8579c3d7f0e33c07c0b8332aa3fe8869688c47b2fbf151e271235.yml
openapi_spec_hash: a49d40286e54da6a4978a103b118d33f
config_hash: cec075ca53645b9620ec200be71bdc48
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/xquik%2Fx-twitter-scraper-3b2c6c771ad1da0bbfeb0af115972929ed2c7fcd5e47a79556d66cd21431b224.yml
openapi_spec_hash: de2890233b68387bf5f9b6d19e7d87dc
config_hash: 8894c96caeb6df84c9394518810221bd
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.2.0 (2026-04-01)

Full Changelog: [v0.1.0...v0.2.0](https://github.com/Xquik-dev/x-twitter-scraper-java/compare/v0.1.0...v0.2.0)

### Features

* **api:** api update ([31b819a](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/31b819aeae39651f9f9204561f6be9719c7a8d6a))
* **api:** api update ([30ac688](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/30ac6883a272290b03f5baa499ae2b61ac168259))


### Chores

* update SDK settings ([e22bccf](https://github.com/Xquik-dev/x-twitter-scraper-java/commit/e22bccf3d47dfd11929924969cb5438b131069f7))

## 0.1.0 (2026-03-30)

Full Changelog: [v0.0.1...v0.1.0](https://github.com/Xquik-dev/x-twitter-scraper-java/compare/v0.0.1...v0.1.0)
Expand Down
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

<!-- x-release-please-start-version -->

[![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)
[![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)
[![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)
[![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)

<!-- x-release-please-end -->

The X Twitter Scraper Java SDK provides convenient access to the [X Twitter Scraper REST API](https://xquik.com) from applications written in Java.

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.

It is generated with [Stainless](https://www.stainless.com/).

<!-- x-release-please-start-version -->

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).
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).

<!-- x-release-please-end -->

Expand All @@ -24,7 +26,7 @@ The REST API documentation can be found on [xquik.com](https://xquik.com). Javad
### Gradle

```kotlin
implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.1.0")
implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.2.0")
```

### Maven
Expand All @@ -33,7 +35,7 @@ implementation("com.x_twitter_scraper.api:x-twitter-scraper-java:0.1.0")
<dependency>
<groupId>com.x_twitter_scraper.api</groupId>
<artifactId>x-twitter-scraper-java</artifactId>
<version>0.1.0</version>
<version>0.2.0</version>
</dependency>
```

Expand All @@ -48,8 +50,8 @@ This library requires Java 8 or later.
```java
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;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;

// Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties
// Or configures using the `X_TWITTER_SCRAPER_API_KEY`, `X_TWITTER_SCRAPER_BEARER_TOKEN` and `X_TWITTER_SCRAPER_BASE_URL` environment variables
Expand All @@ -59,7 +61,7 @@ TweetSearchParams params = TweetSearchParams.builder()
.q("from:elonmusk")
.limit(10L)
.build();
PaginatedTweets paginatedTweets = client.x().tweets().search(params);
TweetSearchResponse response = client.x().tweets().search(params);
```

## Client configuration
Expand Down Expand Up @@ -134,7 +136,7 @@ The `withOptions()` method does not affect the original client or service.

To 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.

For example, `client.x().tweets().search(...)` should be called with an instance of `TweetSearchParams`, and it will return an instance of `PaginatedTweets`.
For example, `client.x().tweets().search(...)` should be called with an instance of `TweetSearchParams`, and it will return an instance of `TweetSearchResponse`.

## Immutability

Expand All @@ -151,8 +153,8 @@ The default client is synchronous. To switch to asynchronous execution, call the
```java
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;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
import java.util.concurrent.CompletableFuture;

// Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties
Expand All @@ -163,16 +165,16 @@ TweetSearchParams params = TweetSearchParams.builder()
.q("from:elonmusk")
.limit(10L)
.build();
CompletableFuture<PaginatedTweets> paginatedTweets = client.async().x().tweets().search(params);
CompletableFuture<TweetSearchResponse> response = client.async().x().tweets().search(params);
```

Or create an asynchronous client from the beginning:

```java
import com.x_twitter_scraper.api.client.XTwitterScraperClientAsync;
import com.x_twitter_scraper.api.client.okhttp.XTwitterScraperOkHttpClientAsync;
import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchParams;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;
import java.util.concurrent.CompletableFuture;

// Configures using the `xtwitterscraper.apiKey`, `xtwitterscraper.bearerToken` and `xtwitterscraper.baseUrl` system properties
Expand All @@ -183,7 +185,7 @@ TweetSearchParams params = TweetSearchParams.builder()
.q("from:elonmusk")
.limit(10L)
.build();
CompletableFuture<PaginatedTweets> paginatedTweets = client.x().tweets().search(params);
CompletableFuture<TweetSearchResponse> response = client.x().tweets().search(params);
```

The asynchronous client supports the same options as the synchronous one, except most methods return `CompletableFuture`s.
Expand Down Expand Up @@ -309,25 +311,25 @@ To access this data, prefix any HTTP method call on a client or service with `wi
```java
import com.x_twitter_scraper.api.core.http.Headers;
import com.x_twitter_scraper.api.core.http.HttpResponseFor;
import com.x_twitter_scraper.api.models.PaginatedTweets;
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();
HttpResponseFor<PaginatedTweets> paginatedTweets = client.x().tweets().withRawResponse().search(params);
HttpResponseFor<TweetSearchResponse> response = client.x().tweets().withRawResponse().search(params);

int statusCode = paginatedTweets.statusCode();
Headers headers = paginatedTweets.headers();
int statusCode = response.statusCode();
Headers headers = response.headers();
```

You can still deserialize the response into an instance of a Java class if needed:

```java
import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;

PaginatedTweets parsedPaginatedTweets = paginatedTweets.parse();
TweetSearchResponse parsedResponse = response.parse();
```

## Error handling
Expand Down Expand Up @@ -425,9 +427,9 @@ Requests time out after 1 minute by default.
To set a custom timeout, configure the method call using the `timeout` method:

```java
import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;

PaginatedTweets paginatedTweets = client.x().tweets().search(
TweetSearchResponse response = client.x().tweets().search(
params, RequestOptions.builder().timeout(Duration.ofSeconds(30)).build()
);
```
Expand Down Expand Up @@ -703,17 +705,17 @@ By default, the SDK will not throw an exception in this case. It will throw [`XT
If you would prefer to check that the response is completely well-typed upfront, then either call `validate()`:

```java
import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;

PaginatedTweets paginatedTweets = client.x().tweets().search(params).validate();
TweetSearchResponse response = client.x().tweets().search(params).validate();
```

Or configure the method call to validate the response using the `responseValidation` method:

```java
import com.x_twitter_scraper.api.models.PaginatedTweets;
import com.x_twitter_scraper.api.models.x.tweets.TweetSearchResponse;

PaginatedTweets paginatedTweets = client.x().tweets().search(
TweetSearchResponse response = client.x().tweets().search(
params, RequestOptions.builder().responseValidation(true).build()
);
```
Expand Down
15 changes: 1 addition & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
plugins {
id("io.github.gradle-nexus.publish-plugin") version "1.1.0"
id("org.jetbrains.dokka") version "2.0.0"
}

Expand All @@ -9,7 +8,7 @@ repositories {

allprojects {
group = "com.x_twitter_scraper.api"
version = "0.1.0" // x-release-please-version
version = "0.2.0" // x-release-please-version
}

subprojects {
Expand All @@ -35,15 +34,3 @@ tasks.named("dokkaJavadocCollector").configure {
.filter { it.project.name != "x-twitter-scraper-java" && it.name == "dokkaJavadocJar" }
.forEach { mustRunAfter(it) }
}

nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))

username.set(System.getenv("SONATYPE_USERNAME"))
password.set(System.getenv("SONATYPE_PASSWORD"))
}
}
}
3 changes: 3 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
plugins {
`kotlin-dsl`
kotlin("jvm") version "1.9.20"
id("com.vanniktech.maven.publish") version "0.28.0"
}

repositories {
gradlePluginPortal()
mavenCentral()
}

dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.20")
implementation("com.vanniktech:gradle-maven-publish-plugin:0.28.0")
}
9 changes: 0 additions & 9 deletions buildSrc/src/main/kotlin/x-twitter-scraper.java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@ repositories {
mavenCentral()
}

configure<JavaPluginExtension> {
withJavadocJar()
withSourcesJar()
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
Expand All @@ -27,10 +22,6 @@ tasks.withType<JavaCompile>().configureEach {
options.release.set(8)
}

tasks.named<Jar>("javadocJar") {
setZip64(true)
}

tasks.named<Jar>("jar") {
manifest {
attributes(mapOf(
Expand Down
Loading
Loading