Stargate Api Rest - datastax-archive/awesome-astra GitHub Wiki
- Rational
- Stargate reference documentations
- way to use it in standalone way
- Astra instance
- Token creation
- Swagger access
- Walkthrough 10 operations through swagger
This walkthrough has been realized using the REST API Quick Start. Here we will the the DATA or SwaggerUI

GET: /v2/schemas/keyspaces

- Click
Try it out - Provide your token in the field
X-Cassandra-Token - Click on
Execute
GET /v2/schemas/keyspaces/{keyspaceName}/tables

- Click
Try it out - Provide your token in the field
X-Cassandra-Token - keyspace:
ks1 - Click on
Execute
GET /v2/schemas/keyspaces/{keyspaceName}/types

- Click
Try it out - X-Cassandra-Token:
<your_token> - keyspace:
ks1 - Click on
Execute
POST /v2/schemas/keyspaces/{keyspaceName}/tables

- Click
Try it out - X-Cassandra-Token:
<your_token> - keyspace:
ks1 - Data
{
"name": "users",
"columnDefinitions":
[
{
"name": "firstname",
"typeDefinition": "text"
},
{
"name": "lastname",
"typeDefinition": "text"
},
{
"name": "email",
"typeDefinition": "text"
},
{
"name": "color",
"typeDefinition": "text"
}
],
"primaryKey":
{
"partitionKey": ["firstname"],
"clusteringKey": ["lastname"]
},
"tableOptions":
{
"defaultTimeToLive": 0,
"clusteringExpression":
[{ "column": "lastname", "order": "ASC" }]
}
}👁️ Expected output
{
"name": "users"
}Notice than for the DML you move to DATA. Make sure you are using url with V2, V1 would also work but this is NOT the same payload.
POST /v2/keyspaces/{keyspaceName}/{tableName}

- X-Cassandra-Token:
<your_token> - keyspaceName:
ks1 - tableName:
users - Data
{
"firstname": "Cedrick",
"lastname": "Lunven",
"email": "[email protected]",
"color": "blue"
}You can note that the output code is 201 and return your primary key `{ "firstname": "Cedrick","lastname": "Lunven" }
- You can add a second record changing only the payload
{
"firstname": "David",
"lastname": "Gilardi",
"email": "[email protected]",
"color": "blue"
}- Add a third
{
"firstname": "Kirsten",
"lastname": "Hunter",
"email": "[email protected]",
"color": "pink"
}-
GET /v2/keyspaces/{keyspaceName}/{tableName}/rows
-
X-Cassandra-Token:
<your_token> -
keyspaceName:
ks1 -
tableName:
users -
Click Execute
-
Notice how now you can only limited return fields
-
fields:
firstname, lastname
GET /v2/keyspaces/{keyspaceName}/{tableName}/{primaryKey}

- X-Cassandra-Token:
<your_token> - keyspaceName:
ks1 - tableName:
users - primaryKey; 'Cedrick`
- Click Execute
- Important: The Swagger user interface is limited as of now and you cannot test a composite key (here adding Lunven). This is a bug in the UI not the API.DELETE /v2/keyspaces/{keyspaceName}/{tableName}/{primaryKey}

- X-Cassandra-Token:
<your_token> - keyspaceName:
ks1 - tableName:
users - primaryKey; 'Cedrick`
- Click Execute
GET /v2/keyspaces/{keyspaceName}/{tableName}

- X-Cassandra-Token:
<your_token> - keyspaceName:
ks1 - tableName:
users - whereClause; '{"firstname": {"$eq":"David"}}`
- Click Execute
I let you try with {"lastname": {"$eq":"Gilardi"}}.. expected right ?
- Provide the Postman collections
- What's next (using HTTP Clients or SDK)