List table names

Tables with the Data API are currently in public preview. Development is ongoing, and the features and functionality are subject to change. Astra DB Serverless, and the use of such, is subject to the DataStax Preview Terms.

Gets the names of the tables in a keyspace.

Method signature

  • Python

  • TypeScript

  • Java

  • curl

The following method belongs to the astrapy.Database class.

list_table_names(
  *,
  keyspace: str,
  table_admin_timeout_ms: int,
  request_timeout_ms: int,
  timeout_ms: int,
) -> list[str]

The following method belongs to the Db class.

async listTables(
  options?: {
    nameOnly: true,
    keyspace?: string,
    timeout?: number | TimeoutDescriptor,
  },
): TableDescriptor[]

The following methods belong to the com.datastax.astra.client.databases.Database class.

List<String> listTableNames()
List<String> listTableNames(ListTablesOptions listTablesOptions)
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 '{
  "listTables": {
    "options": {
      "explain": false
    }
  }
}'

Result

  • Python

  • TypeScript

  • Java

  • curl

Returns the table names as an unordered list of strings.

Example response:

["quickstart_table", "another_table"]

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

Example resolved response:

["quickstart_table", "another_table"]

Returns the table names as an unordered list of strings.

Returns the table names as an unordered list of strings in the status.tables field of the response.

Example response:

{
  "status": {
    "tables":[
      "quickstart_table",
      "another_table"
    ]
  }
}

Parameters

  • Python

  • TypeScript

  • Java

  • curl

Name Type Summary

keyspace

Optional[str]

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

table_admin_timeout_ms

Optional[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.

Name Type Summary

options

ListTablesOptions

The options for this operation.

Options (ListTablesOptions):

Name Type Summary

nameOnly?

boolean

If false or undefined, the response includes table names and metadata. If true, the response includes only table names.

keyspace?

string

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

timeout?

number | TimeoutDescriptor

The client-side timeout for this operation.

Name Type Summary

options

ListTablesOptions

Specialization of the operation, including timeout and keyspace.

Name Type Summary

listTables

command

The Data API command to get a list of tables in a keyspace in a Serverless (Vector) database.

options.explain

boolean

If true, the response includes table names and metadata. If false or unset, the response includes only table names.

Examples

The following examples demonstrate how to list table names.

List table names

  • Python

  • TypeScript

  • Java

  • curl

from astrapy import DataAPIClient

# Get a database
client = DataAPIClient("ASTRA_DB_APPLICATION_TOKEN")
database = client.get_database("ASTRA_DB_API_ENDPOINT")

# List table names
result = database.list_table_names()
print(result)
import { DataAPIClient } from '@datastax/astra-db-ts';

// Get a database
const client = new DataAPIClient('ASTRA_DB_APPLICATION_TOKEN');
const database = client.db('ASTRA_DB_API_ENDPOINT');

// List table names
(async function () {
  const result = await database.listTables({ nameOnly: true });

  console.log(result);
})();
package com.example;

import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;

import java.util.List;

public class ListTableNames {

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

        // List table names
        List<String> result = database.listTableNames();

        System.out.println(result);
    }
}
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 '{
  "listTables": {
    "options": {
      "explain": false
    }
  }
}'

List table names and specify the keyspace

By default, this method uses the working keyspace of your database. If you want to use a different keyspace, you must specify the keyspace.

  • Python

  • TypeScript

  • Java

  • curl

from astrapy import DataAPIClient

# Get a database
client = DataAPIClient("ASTRA_DB_APPLICATION_TOKEN")
database = client.get_database("ASTRA_DB_API_ENDPOINT")

# List table names
result = database.list_table_names(keyspace="KEYSPACE_NAME")
print(result)
import { DataAPIClient } from '@datastax/astra-db-ts';

// Get a database
const client = new DataAPIClient('ASTRA_DB_APPLICATION_TOKEN');
const database = client.db('ASTRA_DB_API_ENDPOINT');

// List table names
(async function () {
  const result = await database.listTables({
    nameOnly: true,
    keyspace: 'KEYSPACE_NAME',
  });

  console.log(result);
})();
package com.example;

import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.databases.Database;
import com.datastax.astra.client.tables.commands.options.ListTablesOptions;

import java.util.List;

public class ListTableNames {

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

        // List table names
        ListTablesOptions options = new ListTablesOptions()
            .keyspace("KEYSPACE_NAME");
        List<String> result = database.listTableNames(options);

        System.out.println(result);
    }
}

This option has no literal equivalent in HTTP. Instead, you always specify the keyspace in the path.

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.

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