The Java SDK provides convenient access to Cognite Data Fusion's capabilities. It covers a large part of CDF's capability surface, including experimental features. In addition, it is designed to handle a lot of the client "chores" for you so you can spend more time on your core client logic.
Some of the SDK's capabilities:
create
and update
for you.Requirements SDK v2:
Requirements SDK v1:
Please refer to the documentation for more information: ./docs/index.md.
We have a new major version of the Java SDK in the pipeline. It is based on the v1 code line, but with a few breaking changes, so we bump it to a new major version. The main breaking changes include:
annotations
api endpoint.It should not be too hard to move from v1 to v2 and we'll provide a migration guide for you.
SDK v2
<dependency>
<groupId>com.cognite</groupId>
<artifactId>cdf-sdk-java</artifactId>
<version>2.3.0</version>
</dependency>
SDK v1
<dependency>
<groupId>com.cognite</groupId>
<artifactId>cdf-sdk-java</artifactId>
<version>1.19.1</version>
</dependency>
// Create the Cognite client with client credentials (OpenID Connect)
CogniteClient client = CogniteClient.ofClientCredentials(
<cdfProject>,
<clientId>,
<clientSecret>,
TokenUrl.generateAzureAdURL(<azureAdTenantId>))
.withBaseUrl("https://yourBaseURL.cognitedata.com"); //optional parameter
// List all assets
List<Asset> listAssetsResults = new ArrayList<>();
client.assets()
.list(Request.create()
.withFilterParameter("key", "value")) //optionally add filter parameters
.forEachRemaining(assetBatch -> listAssetsResults.addAll(assetBatch)); //results are read in batches
// List all events
List<Event> listEventsResults = new ArrayList<>();
client.events()
.list(Request.create()
.withFilterParameter("key", "value")) //optionally add filter parameters
.forEachRemaining(eventBatch -> listEventsResults.addAll(eventBatch)); //results are read in batches