TypeDB Cloud API
The TypeDB Cloud administration API can be used to perform certain actions programmatically, rather than through the TypeDB Cloud website.
To use the API, you will need a TypeDB Cloud account.
Generate an API Token
-
Visit your team settings page, scroll to the API tokens section, and click "Generate API Token".
-
Give your API token a descriptive name, and appropriate access to your chosen space and hit "Create token". See the API reference for detailed access level info.
-
Once created, the token details will be displayed - save the displayed client secret.
|
Make sure to save the client secret somewhere safe - you will only see it when you first generate the token, and will be unable to use the token without it. |
Access the API
Once you have your client ID and client secret, you will need to exchange these for a short-lived access token used to query the API.
-
Make a
POSTrequest tohttps://cloud.typedb.com/api/v1/auth, with the client ID and client secret in a Basic authorization header, separated by a:.-
curl
-
Python
-
Rust
curl --request POST \ --url https://cloud.typedb.com/api/v1/auth \ --header 'Authorization: Basic {CLIENT-ID}:{CLIENT-SECRET}'import requests url = "https://cloud.typedb.com/api/v1/auth" headers = { "Authorization": "Basic {CLIENT-ID}:{CLIENT-SECRET}" } response = requests.post(url, headers=headers)use reqwest; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let client = reqwest::Client::new(); let resp = client .post("https://cloud.typedb.com/api/v1/auth") .header(reqwest::header::AUTHORIZATION, "Basic {CLIENT_ID}:{CLIENT_SECRET}") .send().await; Ok(()) }The response body will be your access token.
For security, your access token will expire after 1 hour.
-
-
Make an API request to list clusters in the space you selected for your API token. The example below targets the
defaultspace in an team calledmy-team. You will use the access token you generated in the previous step to authenticate this request.-
curl
-
Python
-
Rust
curl --request GET \ --url https://cloud.typedb.com/api/v1/team/TEAM_ID/spaces/SPACE_ID/clusters \ --header 'Authorization: Bearer {ACCESS-TOKEN}'import requests url = "https://cloud.typedb.com/api/v1/team/my-team/spaces/default/clusters" headers = { "Authorization": "Bearer {ACCESS-TOKEN}" } response = requests.get(url, headers=headers)use reqwest; #[tokio::main] async fn main() -> Result<(), Box<dyn std::error::Error>> { let client = reqwest::Client::new(); let resp = client .get("https://cloud.typedb.com/api/v1/team/my-team/spaces/default/clusters") .header(reqwest::header::AUTHORIZATION, "Bearer {ACCESS-TOKEN}") .send().await; Ok(()) }It will return information about the clusters in a JSON format, as below
[ { "id":"my-cluster", "serverCount":1, "storageSizeGB":10, "isFree":true, "status":"running", "createdAt":1738256490070, "teamID":"my-team", "spaceID":"default", "version":"3.1.0", "provider":"gcp", "region":"europe-west2", "machineType":"c2d-highcpu-2", "storageType":"standard-rwo", "servers": [ { "address": "abc123-0.cluster.typedb.com:80", "status": "running" } ] } ] -