Connect to a database
When you develop applications that interact with your Astra DB Serverless databases, you must connect to your databases programmatically.
Astra DB Serverless offers several methods to connect to your databases including APIs, CLI tools, and client libraries.
Depending on your use case, you might use one or more of these options.
Use case | Requirements | Recommended methods |
---|---|---|
Application development |
Use a Serverless (Vector) database |
|
Use a Serverless (Non-Vector) database |
||
Use specific CQL functions that aren’t supported by the Data API |
||
Maintain a legacy application that relies on a driver or CQL |
||
Administration |
Perform administrative tasks programmatically |
|
Other |
Streaming |
|
Migration and bulk loading |
|
|
Third-party integrations |
Varies by provider and use case; see Integrations overview |
Programmatic authentication is handled through either application tokens or Secure Connect Bundles. |
APIs
Use the Data API and DevOps API to programmatically interact with your Astra organizations and databases.
DevOps API
Use the DevOps API for administration and high-level database management tasks, such as database creation, user management, and security configurations.
For more information, see Get started with the Astra DevOps API.
Data API
Use the Data API to work with Serverless (Vector) databases, including commands for creating collections and tables, loading data, querying data, and more.
You can access the Data API over HTTP or through the Data API clients.
If you’re new to the Data API, try the quickstart for collections or the quickstart for tables for a demo of some common operations.
For detailed Data API and client reference material, see Get started with the Data API.
Legacy Stargate APIs (deprecated)
Legacy Stargate APIs include the Document API, REST API, GraphQL API, and gRPC API.
The legacy APIs are deprecated for Astra DB Serverless as of September 2024, and end-of-life (EOL) is scheduled for the end of 2025. As EOL approaches, you can do either of the following:
If you have questions or concerns, contact your account representative or DataStax Support. |
Table-based authentication and authorization for legacy APIs
When using the Stargate APIs with Astra DB Serverless, you could use either JWT-based or table-based authentication and authorization.
For example, you can use this REST API command to generate a table-based authentication token, which you then pass to each subsequent request in the X-Cassandra-Token
header:
curl -L -X POST "https://ASTRA_DB_ID-ASTRA_DB_REGION.apps.astra.datastax.com/api/rest/v1/auth" \
-H "Content-Type: application/json" \
--data-raw '{
"username": "CLIENT_ID",
"password": "CLIENT_SECRET"
}'
For more information, see Stargate API Authentication and Authorization.
Clients
You can use the Data API clients to access all Data API commands and some DevOps API endpoints. You can also connect to the Astra DB APIs over HTTP.
Language | Client | Version | Dependency | Documentation |
---|---|---|---|---|
Python |
Python 3.8 or later |
|||
TypeScript |
Node.js 18 or later |
|||
Java |
Java 17 or later (21 recommended) |
If you’re new to the Data API, try the quickstart for collections or the quickstart for tables for a demo of some common operations.
For detailed Data API and client reference material, see Get started with the Data API.
Drivers
You can use drivers to interact with your Astra DB databases, including sending Cassandra Query Language (CQL) statements.
DataStax recommends Data API clients for most applications. Use drivers for Serverless (Non-Vector) databases, legacy applications that rely on a driver, and use cases that require specific CQL functions that aren’t supported by the Data API.
The following drivers are compatible with Astra DB:
Language | Driver | Version | Documentation |
---|---|---|---|
C++ |
|||
C# |
|||
Go |
|||
Java |
|||
Node.js |
|||
Python |
|||
Scala |
Connect to Astra DB Serverless with the Apache Cassandra Spark connector |
If you want to use a CQL driver that isn’t compatible with Astra DB, consider using
|
For more information about drivers, see Cassandra drivers supported by DataStax and Get started with DataStax drivers.
CQL shell
Because Astra DB Serverless is powered by Apache Cassandra®, you can use Cassandra Query Language (CQL) to programmatically interact with your databases through the CQL shell (cqlsh
) or a driver.
For more information, see CQL for Astra DB.
DataStax Bulk Loader
The DataStax Bulk Loader (DSBulk) supports large data uploads and migrations. For more information, see the DataStax Bulk Loader reference.
Astra CLI
The Astra Command-Line Interface (Astra CLI) provides commands you can use to create and manage Astra and Astra Streaming resources.
For example:
-
Create and manage Astra DB databases, Astra Streaming tenants, and their associated artifacts
-
Query and insert data
-
Manage organizations and users
For more information and commands, see the Astra CLI documentation
You can use Astra CLI in addition to other connection methods.
Astra Portal
The Astra Portal provides a web-based interface to manage your Astra organizations and databases. It is best for administrative tasks and high-level database management, including inspecting database health metrics.
For application development, fine-grained data manipulation, and nuanced searches, you must use a programmatic approach.
For information about accessing the Astra Portal, see Manage your Astra account and Firewall rules for the Astra Portal.