Java SDK

Detectant

Detectant Java SDK

Detectant is a malware scanning API with support for Java

Scan files for malware from Java applications.

Install

Maven:

1<dependency>
2 <groupId>com.detectant</groupId>
3 <artifactId>sdk</artifactId>
4 <version>1.0.0</version>
5</dependency>

Gradle:

1implementation "com.detectant:sdk:1.0.0"

Set your API key in the environment:

$export DETECTANT_API_KEY="your-api-key"

Create a client

1import com.detectant.DetectantClient;
2
3DetectantClient detectant = DetectantClient.builder()
4 .apiKey(System.getenv("DETECTANT_API_KEY"))
5 .build();

Scan one file

1import com.detectant.requests.CreateScanRequest;
2import com.detectant.types.Scan;
3import java.io.File;
4
5Scan result = detectant.scan(
6 new File("./invoice.pdf"),
7 CreateScanRequest.builder().build()
8);
9
10System.out.println(result.getVerdict());
11System.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:

1var detectant = AsyncDetectantClient.builder()
2 .apiKey(System.getenv("DETECTANT_API_KEY"))
3 .build();
4
5detectant.scan(
6 new File("./invoice.pdf"),
7 CreateScanRequest.builder().build()
8).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.