Skip to content
xdevplatformPublic

About

Official Java SDK for the X API v2

Resources

Code of conduct

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

XDK Java SDK

Official Java SDK for the X API v2 (Java 17+).

Installation

Maven

<dependency>
    <groupId>com.x</groupId>
    <artifactId>xdk</artifactId>
    <version>0.2.0</version>
</dependency>

Quick Start

import com.x.xdk.XClient;
import com.x.xdk.XClientConfig;
import com.x.xdk.models.Schemas;

XClient client = XClient.builder()
    .bearerToken(System.getenv("X_BEARER_TOKEN"))
    .build();

Schemas.GetUsersByUsernameResponse user =
    client.users().getByUsername("XDevelopers");
System.out.println(user.getData());

Authentication

  • Bearer Token (App-Only): XClient.builder().bearerToken("...").build()
  • OAuth 2.0 User Context & PKCE: OAuth2Pkce + XClient.builder().oauth2(oauth2).build()
  • OAuth 1.0a User Context: OAuth1 + XClient.builder().oauth1(oauth1).build()

Pagination & Streaming

  • Paginated operations have *Pages(...) variants returning Paginator<T> (implementing Iterable<T>) for automatic cursor-based iteration.
  • Streaming operations return EventStream<T> (implementing Iterable<T> and AutoCloseable) with incremental UTF-8 line decoding and exponential backoff reconnection.

Examples & Continuous Canary

  • Runnable Use-Case Examples: See examples/ for end-to-end runnable workflows covering Posts, Search, Users, Bookmarks, Filtered & Sample Streaming, Chunked Media Upload, Direct Messages & XChat, Lists, Spaces, Communities, Community Notes, Trends, News, Webhooks, Compliance, Usage, and OAuth 1.0a / 2.0 PKCE.
  • Continuous Canary Runner: Run mvn test-compile exec:java -Dexec.classpathScope=test -Dexec.mainClass=com.x.xdk.canary.XdkCanaryApp -Dexec.args="--once" (or --daemon --port 8790 for an always-on health & /metrics probe server against the built-in X API simulator or live X_BEARER_TOKEN).

About

Official Java SDK for the X API v2

Resources

Code of conduct

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages