List keyspaces (TypeScript)

Lists all keyspaces in a database.

You need an application token with permission to interact with the target database, such as the Database Administrator role.

For more information, see Get endpoint and token.

Result

Returns a promise that resolves to the keyspace names as a list of strings, with the default keyspace first and the remaining keyspaces in any order.

Parameters

Use the listKeyspaces method, which belongs to the DataAPIDbAdmin class.

Method signature
async listKeyspaces(
  options?: {
    timeout?: number | TimeoutDescriptor,
  }
): void
Name Type Summary

options

object

Optional. The options for this operation. See Properties of options for more details.

Properties of options
Name Type Summary

timeout

number | TimeoutDescriptor

Optional.

The timeout(s) to apply to this method. You can specify requestTimeoutMs and keyspaceAdminTimeoutMs.

For more information about the TimeoutDescriptor, see TypeScript client internals: TimeoutDescriptor. If you specify a number instead of a TimeoutDescriptor object, that number will be applied to both requestTimeoutMs and keyspaceAdminTimeoutMs.

Examples

The following examples demonstrate how to list keyspaces.

List keyspaces

import { DataAPIClient } from "@datastax/astra-db-ts";

// Get a database
const client = new DataAPIClient();
const database = client.db("API_ENDPOINT", {
  token: "APPLICATION_TOKEN",
});

// Get an admin object
const admin = database.admin();

// List keyspaces
(async function () {
  const keyspaces = await admin.listKeyspaces();

  console.log(keyspaces);
})();

Client reference

For more information, see the client reference.

Was this helpful?

Give Feedback

How can we improve the documentation?

© Copyright IBM Corporation 2026 | Privacy policy | Terms of use Manage Privacy Choices

Apache, Apache Cassandra, Cassandra, Apache Tomcat, Tomcat, Apache Lucene, Apache Solr, Apache Hadoop, Hadoop, Apache Pulsar, Pulsar, Apache Spark, Spark, Apache TinkerPop, TinkerPop, Apache Kafka and Kafka are either registered trademarks or trademarks of the Apache Software Foundation or its subsidiaries in Canada, the United States and/or other countries. Kubernetes is the registered trademark of the Linux Foundation.

General Inquiries: Contact IBM