> ## Documentation Index
> Fetch the complete documentation index at: https://docs.x.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Make your first X API v2 request with the Java XDK.

**1. Add the dependency**

```xml theme={null}
<dependency>
  <groupId>com.x</groupId>
  <artifactId>xdk</artifactId>
  <version>0.1.2</version>
</dependency>
```

**2. Export your Bearer Token**

Generate a **Bearer Token** in the [X Developer Console](https://console.x.com) and set it in your shell:

```bash theme={null}
export X_BEARER_TOKEN="your_bearer_token_here"
```

**3. Run a lookup and search**

```java theme={null}
import com.x.xdk.Schemas;
import com.x.xdk.XClient;
import com.x.xdk.clients.PostsClient;
import java.util.List;

public class Quickstart {
    public static void main(String[] args) {
        XClient client = XClient.builder()
            .bearerToken(System.getenv("X_BEARER_TOKEN"))
            .build();

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

        Schemas.SearchPostsRecentResponse posts = client.posts().searchRecent(
            "from:XDevelopers -is:retweet",
            PostsClient.SearchRecentOptions.builder()
                .maxResults(10)
                .postFields(List.of("created_at", "public_metrics"))
        );
        System.out.println("Posts: " + posts.getData());
    }
}
```

## Next steps

* [Authentication](https://docs.x.com/xdks/java/authentication.md) — Bearer Token, OAuth 2.0 PKCE, and OAuth 1.0a
* [Pagination](https://docs.x.com/xdks/java/pagination.md) — Iterate pages with `Paginator<T>`
* [Streaming](https://docs.x.com/xdks/java/streaming.md) — Read live streams with `EventStream<T>`
* [Code samples](https://github.com/xdevplatform/samples/tree/main/java) — Runnable Java examples
