Skip to navigation

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:

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

Gradle:

implementation "com.detectant:sdk:1.0.0"

Set your API key in the environment:

export DETECTANT_API_KEY="your-api-key"

Create a client

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

Scan one file

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:

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.