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

# Java SDK

> Java client library for News API

Java SDK provides access to the News API from Java or Kotlin applications.

## Installation

### Gradle

```groovy theme={null}
dependencies {
    implementation 'com.newscatcherapi:newscatcher-sdk:2.0.0'
}
```

### Maven

```xml theme={null}
<dependency>
    <groupId>com.newscatcherapi</groupId>
    <artifactId>newscatcher-sdk</artifactId>
    <version>2.0.0</version>
</dependency>
```

## Basic usage

```java theme={null}
import com.newscatcher.api.NewscatcherApiClient;
import com.newscatcher.api.resources.search.requests.PostSearchRequest;

NewscatcherApiClient client = NewscatcherApiClient.builder()
    .apiKey("YOUR_API_KEY")
    .build();

client.search().post(PostSearchRequest.builder()
    .q("renewable energy")
    .lang(Arrays.asList("en"))
    .build());
```

## Error handling

```java theme={null}
import com.newscatcher.api.core.NewscatcherApiApiException;

try {
    client.search().post(...);
} catch (NewscatcherApiApiException e) {
    System.out.println(e.getMessage());
    System.out.println(e.statusCode());
    System.out.println(e.body());
}
```

For complete documentation, including specific error types and configuration
options, see the
[GitHub repository](https://github.com/Newscatcher/newscatcher-java).

## Resources

* [GitHub repository](https://github.com/Newscatcher/newscatcher-java)
* [Maven Central](https://central.sonatype.com/artifact/com.newscatcherapi/newscatcher-sdk)
