List collection metadata

Gets information about the collections in a keyspace.

Ready to write code? See the examples for this method to get started. If you are new to the Data API, check out the quickstart.

Result

  • Python

  • TypeScript

  • Java

  • curl

  • CLI

Returns a list of CollectionDescriptor objects that describe each collection.

Example response:

[
  CollectionDescriptor(
    name='my_collection',
    definition=CollectionDefinition(
      indexing={'allow': ['country', 'city']}
    ),
    raw_descriptor=...
  ),
  CollectionDescriptor(
    name='my_vector_collection',
    definition=CollectionDefinition(
      vector=CollectionVectorOptions(
        dimension=3,
        metric='dot_product',
        source_model='other',
        service=None
      ),
    ),
    raw_descriptor=...
  )
]

Returns a promise that resolves to an array of CollectionDescriptor objects that describe each collection.

Returns a List<CollectionDescriptor>, where each CollectionDescriptor object describes a collection.

The status.collections field in the response describes each collection.

Example response:

{
  "status" : {
    "collections" : [
      {
        "name" : "student_collection",
        "options" : {
          "defaultId": {
            "type": "objectId"
          },
          "vector" : {
            "dimension" : 5,
            "metric" : "cosine"
          }
        }
      },
      {
        "name" : "book_collection",
        "options" : {
          "defaultId": {
            "type": "objectId"
          },
          "vector" : {
            "dimension" : 5,
            "metric" : "cosine"
          }
        }
      }
    ]
  }
}

Prints details about each collection.

Example response:

+---------------------+-----------+-------------+
| Name                | Dimension | Metric      |
+---------------------+-----------+-------------+
| collection_simple   |           |             |
| collection_vector   | 14        | cosine      |
| msp                 | 1536      | dot_product |
+---------------------+-----------+-------------+

Parameters

  • Python

  • TypeScript

  • Java

  • curl

  • CLI

Use the list_collections method, which belongs to the astrapy.Database class.

Method signature
list_collections(
  *,
  keyspace: str,
  collection_admin_timeout_ms: int,
  request_timeout_ms: int,
  timeout_ms: int,
) -> list[CollectionDescriptor]
Name Type Summary

keyspace

str

Optional. The keyspace to inspect.

Default: The database’s working keyspace.

collection_admin_timeout_ms

int

A timeout, in milliseconds, for the underlying HTTP request. If not provided, the Database setting is used. This parameter is aliased as request_timeout_ms and timeout_ms for convenience.

Use the listCollections method, which belongs to the Db class.

Method signature
async listCollections(
  options: {
    nameOnly?: false,
    keyspace?: string,
    timeout?: number | TimeoutDescriptor,
  }
): CollectionDescriptor[]
Name Type Summary

options

ListCollectionsOptions

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

Properties of options
Name Type Summary

nameOnly

false

Must be false to return metadata about the collection. Otherwise, only the collection names are returned.

keyspace

string

Optional. The keyspace to inspect.

Default: The database’s working keyspace.

timeout

number | TimeoutDescriptor

Optional.

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

Details about the timeout parameter

The TimeoutDescriptor object can contain these properties:

  • requestTimeoutMs (number): The maximum time, in milliseconds, that the client should wait for each underlying HTTP request. Default: The default value for the collection. This default is 10 seconds unless you specified a different default when you initialized the Collection or DataAPIClient object.

  • collectionAdminTimeoutMs (number): The maximum time, in milliseconds, for collection admin operations like creating, dropping, and listing collections. Default: The default value for the collection. This default is 60 seconds unless you specified a different default when you initialized the Collection or DataAPIClient object.

If you specify a number instead of a TimeoutDescriptor object, that number will be applied to both requestTimeoutMs and collectionAdminTimeoutMs.

Use the listCollections method, which belongs to the com.datastax.astra.client.Database class.

Method signature
List<CollectionDescriptor> listCollections()
List<CollectionDescriptor> listCollections(ListCollectionOptions options)
Name Type Summary

options

ListCollectionOptions

Optional. The options for this operation, including the keyspace and timeouts.

Use the findCollections command.

Command signature
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "findCollections": {
    "options": {
      "explain": true
    }
  }
}'
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

true

Must be true to return metadata about the collection. Otherwise, only the collection names are returned.

Command signature
astra db list-collections DATABASE_ID
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 metadata.

  • Python

  • TypeScript

  • Java

  • curl

  • CLI

from astrapy import DataAPIClient

# Get a database
client = DataAPIClient()
database = client.get_database(
    "API_ENDPOINT",
    token="APPLICATION_TOKEN",
)

# List collections
database.list_collections()
import { DataAPIClient } from "@datastax/astra-db-ts";

// Get a database
const client = new DataAPIClient("APPLICATION_TOKEN");
const database = client.db("API_ENDPOINT");

// List collections
(async function () {
  await database.listCollections({ nameOnly: false });
})();
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.collections.definition.CollectionDescriptor;
import com.datastax.astra.client.databases.Database;
import java.util.List;

public class Example {

  public static void main(String[] args) {
    // Get a database
    Database database = new DataAPIClient("APPLICATION_TOKEN").getDatabase("API_ENDPOINT");

    // List collections
    List<CollectionDescriptor> collectionMetadata = database.listCollections();
    collectionMetadata.stream().map(CollectionDescriptor::getOptions).forEach(System.out::println);
  }
}
curl -sS -L -X POST "API_ENDPOINT/api/json/v1/KEYSPACE_NAME" \
--header "Token: APPLICATION_TOKEN" \
--header "Content-Type: application/json" \
--data '{
  "findCollections": {
    "options": {
      "explain": true
    }
  }
}'
astra db list-collections DATABASE_ID

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