-
Notifications
You must be signed in to change notification settings - Fork 11
Home
The SDK makes it easy to call Stargate and/or Astra services using idiomatic Java APIs. On top of the SDK, the repository provides a Spring Boot starter to ease integration with Spring Application.

You need JDK 11.0.9+ and a dependency management tool such as Maven or Gradle. (The SDK has been build with the HttpClient provided in JDK 11) It is a single library providing support for the 5 API(s) listed above. Please change the SDK-version with the latest version.
Maven dependency in pom.xml
<dependency>
<groupId>com.datastax.astra</groupId>
<artifactId>astra-sdk-java</artifactId>
<version>${SDK-version}</version>
</dependency>Gradle dependency in build.gradle
dependencies {
astra_sdk 'com.datastax.astra:astra-sdk-java:${sdk-version}'
}To use Astra you need an Astra account and credentials with Astra Token. Then, based on the values you provided the underlying Apis will be enabled or not.
Please follow those 2 tutorials to set up your instance
AstraClient client = AstraClient.builder()
.appToken("AstraCS:......"). // App Token will be used as ApiKey for Devops, Docs and REST Api.
.databaseId("astra_cluster_id"). // Unique identifier for your instance
.cloudProviderRegion("astra_db_region") // Cloud Provider region picked for you instance
// (For CqlSession only)
.clientId("TWRvjlcrgfZYfhcxGZhUlAAA") // Will be used as your username
.clientSecret("7xKSrZPLbWxDJ0WXyj..") // Will be used as your password
.keyspace("ks1") // (optional) Set your keyspace
.secureConnectBundle("/tmp/sec.zip"). // (optional) if not provided download in ~/.astra
.build();| Param Name | DevOps API | REST and Docs API | GraphQL API | CqlSession API |
|---|---|---|---|---|
| application Token (part of token) | required |
required |
required |
-- |
clientId (part of token) |
optional |
-- | -- | required |
clientSecret (part of token) |
optional |
-- | -- | required |
databaseId |
-- | required |
required |
required |
database Cloud Region |
-- | required |
required |
required |
keyspace |
-- | -- | -- | optional |
| Secure Connect Bundle | -- | -- | -- | optional |
Astra is not required to work with the SDK. A standalone installation of Stargate exposes the Rest/Document/Graph Apis and the CqlSession.
To install Stargate on your environment please check out the following guide
Instead of the token shown for Astra, you will use a user and a password and will authenticate against a dedicated authenticationUrl. Make sure to create a user at the Cassandra level and enable RBAC.
StargateClient client = StargateClient.builder()
.username("k8ssandra-superuser") // Mandatory username
.password("JxzrPOnvDGqfEOQ0EySQ") // Mandatory password
.endPointAuth("http://localhost:8081") // Mandatory authencation url, defaulting to http://localhost:8081
.endPointRest("http://localhost:8082") // Rest and Document Apis
.endPointGraphQL("http://localhost:8080") // GraphQL Api
// Cqlsession Only
.addCqlContactPoint("127.0.0.", 9042) // Contact Point
.localDc("dc1") // Local Datacenter is mandatory driver 4x+
.keypace("ks1") // (optional) Set your keyspace
.build();| Param Name | REST and Doc APIs | GraphQL API | CqlSession API |
|---|---|---|---|
| username | required |
required |
required |
| password | required |
required |
required |
| Authentication endpoint | required |
required |
required |
| Rest Api endpoint | required |
-- | -- |
| GraphQL Api endpoint | -- | required |
-- |
| Contact Points | -- | -- | required |
Local DataCenter Name (localDc) |
-- | -- | required |
| keyspace | -- | -- | optional |
How do you want to connect?
| Choice | Description |
|---|---|
| Operate Astra (provisionning, IAM) | Use the Devops API |
| ReUse DataStax drivers | Use the CQL API leveraging DataStax drivers to manage database connections for your application. |
| Use Schemaless | Use schemaless JSON Documents with the Document API |
| Same interfaces as drivers in REST | Use the REST API or GraphQL API to begin interacting with your database. |
🏠 Home | Document | Rest | Native Drivers | GraphQL | gRPC | Astra Devops |