Find all databases
Retrieve the listing of all databases.
|
You need an application token with permission to create and configure databases, such as the Organization Administrator role. For more information, see Get endpoint and token. |
Result
-
Python
-
TypeScript
-
Java
-
curl
Returns:
list[AstraDBAdminDatabaseInfo] - A list of objects, each carrying detailed information on a database.
Result
This example is abridged and reformated in pprint-style for clarity.
It shows a single AstraDBAdminDatabaseInfo from the list.
[
...,
AstraDBAdminDatabaseInfo(
id=01234567-89ab-cdef-0123-456789abcdef,
name=my_database,
keyspaces=['default_keyspace', 'alternate_keyspace'],
status=ACTIVE,
environment=prod,
cloud_provider=AWS,
created_at=2024-12-17 21:52:43+00:00,
last_used=2025-04-02 14:31:04+00:00,
org_id=aabbccdd-eeff-0011-2233-445566778899,
owner_id=00112233-4455-6677-8899aabbddeeff,
regions=[
AstraDBAdminDatabaseRegionInfo(
name=us-east-2,
id=01234567-89ab-cdef-0123-456789abcdef-1,
api_endpoint=https://01234567-89ab-cdef-0123-456789abcdef-us-east-2.apps.astra.datastax.com,
created_at=2024-12-17 21:52:43+00:00
)
],
raw=...
)
...,
]
Returns:
Promise<FullDatabaseInfo[]> - A promised list of the complete information for all the databases matching the given filter.
Returns:
List<DatabaseInfo> - List of database metadata exposed as a stream.
Returns:
A successful request returns 200 Success and an array of objects containing information about each database in the organization.
Result
This example response contains one database object, and it is truncated for brevity.
[
{
"id": "DB_ID",
"orgId": "organizations/ORG_ID",
"ownerId": "users/USER_ID",
"info": {
"name": "DB_NAME",
"keyspace": "INITIAL_KEYSPACE_NAME",
"cloudProvider": "CLOUD_PROVIDER",
"region": "REGION",
"additionalKeyspaces": [
"SECOND_KEYSPACE_NAME"
],
"dbType": "vector"
},
"creationTime": "2012-11-01T22:08:41+00:00",
"terminationTime": "2019-11-01T22:08:41+00:00",
"status": "ACTIVE",
# Response truncated for brevity
}
]
Parameters
-
Python
-
TypeScript
-
Java
-
curl
This operation is done through an instance of the AstraDBAdmin class.
all_databases = admin.list_databases()
Parameters:
| Name | Type | Summary |
|---|---|---|
|
|
A filter on what databases are to be returned. As per DevOps API, defaults to "nonterminated". Use "all" to include the already terminated databases. |
|
|
A filter on the cloud provider for the databases. As per DevOps API, defaults to "ALL". Pass e.g. "AWS" to restrict the results. |
|
|
Number of results per page from the DevOps API. If omitted, the DevOps API employs its defaults. In case the requested databases exceed one page of results, the method manages pagination for you until exhaustion, returning the full list at once. |
|
|
A timeout, in milliseconds, to impose on the
underlying API request. If not provided, the default settings of the Note: while in the case of very many databases this method may entail multiple DevOps API requests, it is assumed here that this method amounts almost always to one single request: the only timeout imposed on this method execution is one acting on each individual request, with no checks on its overall completion time. |
This operation is done through an instance of the AstraAdmin class.
const dbs = await admin.listDatabases();
Parameters:
| Name | Type | Summary |
|---|---|---|
|
The filters to use when listing the database |
Options (ListAstraDatabasesOptions):
| Name | Type | Summary |
|---|---|---|
Allows filtering by database status. Defaults to |
||
Allows filtering by cloud provider. Defaults to |
||
|
Number of databases to return, between 1-100. Defaults to 25. |
|
|
Number of databases to skip. Defaults to 0. |
|
|
The timeouts for this method. |
The list databases function is available in the AstraDBAdmin class.
// Given 'admin' a AstraDBAdmin object
List<DatabaseInfo> infoList = admin.listDatabases();
Parameters:
None.
Use the DevOps API to get information about all databases in an organization.
The application token must have sufficient permissions to perform the requested operations, such as the Organization Administrator role. Additionally, the application token identifies the organization to query.
Examples
The following examples demonstrate how to list databases.
-
Python
-
TypeScript
-
Java
-
curl
from astrapy import DataAPIClient
client = DataAPIClient("TOKEN")
admin = client.get_admin()
database_list = admin.list_databases()
len(database_list)
# 3
database_list[2].id
# '01234567-...'
database_list[2].status
# 'ACTIVE'
database_list[2].regions[0].name
# 'eu-west-1'
import { DataAPIClient } from '@datastax/astra-db-ts'
const admin = new DataAPIClient('TOKEN').admin();
(async function () {
const activeDbs = await admin.listDatabases({ include: 'ACTIVE' });
for (const db of activeDbs) {
console.log(`Database ${db.name} is active`);
}
})();
package com.datastax.astra.client.admin;
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.definition.DatabaseInfo;
public class ListDatabases {
public static void main(String[] args) {
// Initialization of admin (astra only)
AstraDBAdmin astraDBAdmin = new DataAPIClient("TOKEN").getAdmin();
// Display all database information
astraDBAdmin.listDatabases().stream()
.map(DatabaseInfo::getId)
.forEach(System.out::println);
// Display all database names
astraDBAdmin.listDatabaseNames();
}
}
curl -sS -L -X GET "https://api.astra.datastax.com/v2/databases" \
--header "Authorization: Bearer APPLICATION_TOKEN" \
--header "Content-Type: application/json"
Client reference
-
Python
-
TypeScript
-
Java
-
curl
For more information, see the client reference.
For more information, see the client reference.
For more information, see the client reference.
Client reference documentation is not applicable for HTTP.