> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.detectant.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.detectant.com/_mcp/server.

![Detectant](https://www.detectant.com/images/detectant-github-banner.png)

# Detectant Java SDK

[Detectant is a malware scanning API with support for Java](https://www.detectant.com)

Scan files for malware from Java applications.

## Install

Maven:

```xml
<dependency>
  <groupId>com.detectant</groupId>
  <artifactId>sdk</artifactId>
  <version>1.0.0</version>
</dependency>
```

Gradle:

```groovy
implementation "com.detectant:sdk:1.0.0"
```

Set your API key in the environment:

```bash
export DETECTANT_API_KEY="your-api-key"
```

## Create a client

```java
import com.detectant.DetectantClient;

DetectantClient detectant = DetectantClient.builder()
    .apiKey(System.getenv("DETECTANT_API_KEY"))
    .build();
```

## Scan one file

```java
import com.detectant.requests.CreateScanRequest;
import com.detectant.types.Scan;
import java.io.File;

Scan result = detectant.scan(
    new File("./invoice.pdf"),
    CreateScanRequest.builder().build()
);

System.out.println(result.getVerdict());
System.out.println(result.getDetections());
```

The call completes after the file has been analyzed and returns its scan result. Input streams are also supported when a filename is supplied.

## Async client

Use `AsyncDetectantClient` for non-blocking calls:

```java
var detectant = AsyncDetectantClient.builder()
    .apiKey(System.getenv("DETECTANT_API_KEY"))
    .build();

detectant.scan(
    new File("./invoice.pdf"),
    CreateScanRequest.builder().build()
).thenAccept(result -> System.out.println(result.getVerdict()));
```

Requests retry transient failures twice by default. Configure timeouts, retries, and a custom OkHttp client through the builder.

## Source

The SDK is generated with Fern and maintained at [Detectant/java-sdk](https://github.com/Detectant/java-sdk).