List collection names

Gets the names of the collections in a keyspace.

Method signature

  • Python

  • TypeScript

  • Java

  • curl

  • CLI

database.list_collection_names(
  *,
  keyspace: str,
  max_time_ms: int,
) -> list[str]
database.listCollections(
  options: {
    nameOnly?: boolean,
    keyspace?: string,
    maxTimeMS?: number,
  }
): Promise<string[]>
Stream<String> listCollectionNames()
curl -sS -L -X POST "ASTRA_DB_API_ENDPOINT/api/json/v1/ASTRA_DB_KEYSPACE" \
--header "Token: ASTRA_DB_APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "findCollections": {
    "options": {
      "explain": false
    }
  }
}'
astra db list-collections DATABASE_ID | cut -b 1-23

Result

  • Python

  • TypeScript

  • Java

  • curl

  • CLI

Returns the collection names as an unordered list of strings.

Example response:

["quickstart_collection", "another_collection"]

Returns a promise that resolves to the collection names as an unordered list of strings.

Example resolved response:

["quickstart_collection", "another_collection"]

Returns the collection names as a Stream of strings.

Returns the collection names as an unordered list of strings in the status.collections field of the response.

Example response:

{
  "status": {
    "collections":[
      "quickstart_collection",
      "another_collection"
    ]
  }
}

Prints the names of the collections.

Example response:

+---------------------+
| Name                |
+---------------------+
| collection_simple   |
| collection_vector   |
| msp                 |
+---------------------+

Parameters

  • Python

  • TypeScript

  • Java

  • curl

  • CLI

Name Type Summary

keyspace

Optional[str]

The keyspace to be inspected. If not specified, the database’s working keyspace is used.

max_time_ms

Optional[int]

A timeout, in milliseconds, for the underlying HTTP request.

Name Type Summary

options

ListCollectionsOptions

Options regarding listing collections.

Name Type Summary

nameOnly

true

If true, only the name of the collection is returned. Else, the full information for each collection is returned. Defaults to true.

keyspace?

string

The keyspace to be inspected. If not specified, the database’s working keyspace is used.

maxTimeMs?

number

Maximum time in milliseconds the client should wait for the operation to complete.

For details about each parameter, see the client reference.

Name Type Summary

findCollections

command

The Data API command to find all collections in the specified database and keyspace. It acts as a container for all the attributes and settings required to find collections.

options.explain

boolean

If true, the response includes collection names and a brief explanation of metadata for each collection. If false or unset, the response includes only collection names.

Name Type Summary

DATABASE_ID

String

To get the DATABASE_ID, see Get your database ID.

Examples

The following examples demonstrate how to get collection names.

  • Python

  • TypeScript

  • Java

  • curl

  • CLI

database.list_collection_names()

Get the names of the collections in a specified keyspace of the database.

database.list_collection_names(keyspace="KEYSPACE_NAME")

Example:

from astrapy import DataAPIClient
client = DataAPIClient("TOKEN")
database = client.get_database("API_ENDPOINT")

database.list_collection_names()
# ['a_collection', 'another_col']
const collectionNames = await db.listCollections({ nameOnly: true });

Get the names of the collections in a specified keyspace of the database.

const collectionNames = await db.listCollections({ nameOnly: true, keyspace: 'KEYSPACE_NAME' });

Example:

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

// Get a new Db instance
const db = new DataAPIClient('TOKEN').db('API_ENDPOINT');

(async function () {
  // Gets just names of all collections in db
  const collections = await db.listCollections({ nameOnly: true });

  for (const collectionName of collections) {
    console.log(`Collection '${collectionName}' exists`);
  }
})();
// Given `db` Database object, list all collections
Stream<String> collection = listCollectionsNames();

Example:

package com.datastax.astra.client.database;

import com.datastax.astra.client.Database;
import com.datastax.astra.client.model.CollectionInfo;

import java.util.stream.Stream;

public class ListCollections {
    public static void main(String[] args) {
        Database db = new Database("TOKEN", "API_ENDPOINT");

        // Get collection Names
        Stream<String> collectionNames = db.listCollectionNames();

        // Get Collection information (with options)
        Stream<CollectionInfo> collections = db.listCollections();
        collections.map(CollectionInfo::getOptions).forEach(System.out::println);
    }
}
curl -sS -L -X POST "ASTRA_DB_API_ENDPOINT/api/json/v1/ASTRA_DB_KEYSPACE" \
--header "Token: ASTRA_DB_APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "findCollections": {
    "options": {
      "explain": false
    }
  }
}'
astra db list-collections DATABASE_ID | cut -b 1-23

Client reference

  • Python

  • TypeScript

  • Java

  • curl

  • CLI

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.

For more information, see the Astra CLI documentation.

Was this helpful?

Give Feedback

How can we improve the documentation?

© 2025 DataStax | 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: +1 (650) 389-6000, info@datastax.com