Java SDK
Current Status
The Java SDK for Spartera is currently not available. The official Java SDK
repository appears to be either unreleased or deprecated.
Alternative Solutions
While waiting for the official Java SDK, you can integrate with Spartera
using the following approaches:
REST API Integration
Use Java HTTP clients to interact directly with the Spartera REST API:
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;
public class SparteraClient {
private final HttpClient httpClient;
private final String apiKey;
private final String baseUrl = "https://api.spartera.com";
public SparteraClient(String apiKey) {
this.httpClient = HttpClient.newHttpClient();
this.apiKey = apiKey;
}
public String createConnection(String jsonBody) throws Exception {
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(baseUrl + "/connections"))
.header("Content-Type", "application/json")
.header("X-API-Key", apiKey)
.POST(HttpRequest.BodyPublishers.ofString(jsonBody))
.build();
HttpResponse<String> response = httpClient.send(request,
HttpResponse.BodyHandlers.ofString());
return response.body();
}
}
Spring Boot Integration
For Spring Boot applications, use RestTemplate or WebClient:
@Service
public class SparteraService {
@Value("${spartera.api.key}")
private String apiKey;
private final RestTemplate restTemplate;
public SparteraService(RestTemplate restTemplate) {
this.restTemplate = restTemplate;
}
public ResponseEntity<String> createAsset(Object asset) {
HttpHeaders headers = new HttpHeaders();
headers.set("X-API-Key", apiKey);
headers.setContentType(MediaType.APPLICATION_JSON);
HttpEntity<Object> entity = new HttpEntity<>(asset, headers);
return restTemplate.postForEntity(
"https://api.spartera.com/assets",
entity,
String.class
);
}
}
OkHttp Client Example
Using the popular OkHttp library:
import okhttp3.*;
import java.io.IOException;
public class SparteraOkHttpClient {
private final OkHttpClient client = new OkHttpClient();
private final String apiKey;
public SparteraOkHttpClient(String apiKey) {
this.apiKey = apiKey;
}
public String getAssets() throws IOException {
Request request = new Request.Builder()
.url("https://api.spartera.com/assets")
.addHeader("X-API-Key", apiKey)
.build();
try (Response response = client.newCall(request).execute()) {
return response.body().string();
}
}
}
Configuration
Add necessary dependencies to your pom.xml:
<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.12.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>
</dependencies>
Future Updates
Check the official Spartera documentation for updates on Java SDK
availability. The REST API provides complete functionality for all
Spartera features.
