Document API

DataStax Astra DB uses the Stargate Document API to modify and query data stored as unstructured JSON documents in collections. Because the Document API uses schemaless data, no data modeling is required!

The blog The Stargate Cassandra Documents API describes the underlying structure used to store collections.

Information about namespaces and collections.

To use the Document API, you must define the namespace that will store collections. Collections store unstructured JSON documents. Documents can themselves hold multiple documents. Multiple collections are contained in a namespace, but a collection cannot be contained in multiple namespaces.

Only namespaces need to specifically created. Collections are specified when a document is inserted.

Swagger UI for the Document API

You can access the Document API in a browser with Swagger UI at https://$ASTRA_CLUSTER_ID-$ASTRA_REGION.apps.astra.datastax.com/api/rest/swagger-ui/. Adding parameter information, you can generate cURL commands to execute and display results that will return.

Using Postman

If you prefer, you can use Postman as a client interface for exploring the Document API (download here). We’ve provided a Stargate Document API Postman Astra Collection that you can import in Postman to play with the examples shown in this walkthrough.

Prerequisites

Before you get started, set your environment variables to save time developing on your database.

  1. In Astra, select the database to which you want to connect.

  2. In your Database Dashboard, select Connect.

  3. Select Document API.

    If you have multiple regions, select the region you want to connect to from the dropdown menu for instructions.

  4. Follow the steps in the prerequisites to get your application token and set up your environment variables.

  5. In your command-line interface associated with your environment, paste the following environment variables copied for your Astra database:

export ASTRA_DB_ID=<database_id>
export ASTRA_DB_REGION=<database_region>
export ASTRA_DB_KEYSPACE=<keyspace_name>
export ASTRA_DB_APPLICATION_TOKEN=<app_token>

Now you are ready to get started:

To view the API Reference, see Astra DB Document API.