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. Hyper-Converged Database (HCD), and the use of such, is subject to the DataStax Preview Terms.

Gets the names of the tables 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

Returns the table names as an unordered list of strings.

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

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

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

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

keyspace

str

Optional if you specified a keyspace when instantiating the Database object. The keyspace to inspect.

Default: The database’s working keyspace.

table_admin_timeout_ms

int

Optional. 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 listTables method, which belongs to the Db class.

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

options

ListTablesOptions

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

Properties of options
Name Type Summary

nameOnly

true

Must be true to return only the table names. Otherwise, additional metadata about the tables is returned.

keyspace

string

Optional if you specified a keyspace when instantiating the Db object. The keyspace to inspect.

Default: The database’s working keyspace.

timeout

number | TimeoutDescriptor

Optional. A timeout to impose on the underlying API request.

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

Method signature
List<String> listTableNames()
List<String> listTableNames(ListTablesOptions listTablesOptions)
Name Type Summary

options

ListTablesOptions

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

Use the listTables 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 '{
  "listTables": {
    "options": {
      "explain": false
    }
  }
}'
Name Type Summary

options.explain

false

Must be false to return only the table names. Otherwise, additional metadata about the tables is returned.

Examples

The following examples demonstrate how to list table names.

List table names

  • Python

  • TypeScript

  • Java

  • curl

from astrapy import DataAPIClient
from astrapy.authentication import UsernamePasswordTokenProvider
from astrapy.constants import Environment

# Get a database
client = DataAPIClient(environment=Environment.HCD)
database = client.get_database(
    "API_ENDPOINT",
    token=UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
)

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

// Get a database
const client = new DataAPIClient({ environment: "hcd" });
const database = client.db("API_ENDPOINT", {
  token: new UsernamePasswordTokenProvider("USERNAME", "PASSWORD"),
});

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

  console.log(result);
})();
import com.datastax.astra.client.DataAPIClient;
import com.datastax.astra.client.DataAPIClients;
import com.datastax.astra.client.databases.Database;
import java.util.List;

public class Example {

  public static void main(String[] args) {
    // Get a database
    DataAPIClient client = DataAPIClients.clientHCD("USERNAME", "PASSWORD");
    Database database = client.getDatabase("API_ENDPOINT", "KEYSPACE_NAME");

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

    System.out.println(result);
  }
}
curl -sS -L -X POST "API_ENDPOINT/v1/KEYSPACE_NAME" \
  --header "Token: APPLICATION_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
  "listTables": {
    "options": {
      "explain": false
    }
  }
}'

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, an IBM Company | 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