Skip to main content
GET
/
v1
/
organizations
/
{organizationSlug}
/
databases
/
{databaseName}
/
usage
curl -L -X GET 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases/{databaseName}/usage?from=2023-01-01T00:00:00Z&to=2023-02-01T00:00:00Z' \
-H 'Authorization: Bearer TOKEN'
import { createClient } from "@tursodatabase/api";

const turso = createClient({
  org: "...",
  token: "",
});

const usageStatsWithDate = await turso.databases.usage("my-db");

const usageStatsWithDate = await turso.databases.usage("my-db", {
  from: new Date("2023-01-01"),
  to: new Date("2023-02-01"),
});

const usageStatsWithString = await turso.databases.usage("my-db", {
  from: "2023-01-01T00:00:00Z",
  to: "2023-02-01T00:00:00Z",
});
{
  "database": {
    "uuid": "<unknown>",
    "instances": [
      {
        "uuid": "cd831986-94e5-11ee-a6fe-7a52e1f7759a",
        "usage": {
          "rows_read": 0,
          "rows_written": 0,
          "storage_bytes": 4096,
          "bytes_synced": 0
        }
      },
      {
        "uuid": "0be90471-6906-11ee-8553-eaa7715aeaf2",
        "usage": {
          "rows_read": 0,
          "rows_written": 0,
          "storage_bytes": 4096,
          "bytes_synced": 0
        }
      }
    ],
    "total": {
      "rows_read": 0,
      "rows_written": 0,
      "storage_bytes": 8192,
      "bytes_synced": 0
    }
  }
}
{
"error": "invalid from parameter: parsing time \"2023-12-12T00:00:00\" as \"2006-01-02T15:04:05Z07:00\": cannot parse \"\" as \"Z07:00\""
}
{
"error": "could not find database with name [databaseName]: record not found"
}
curl -L -X GET 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases/{databaseName}/usage?from=2023-01-01T00:00:00Z&to=2023-02-01T00:00:00Z' \
-H 'Authorization: Bearer TOKEN'
import { createClient } from "@tursodatabase/api";

const turso = createClient({
  org: "...",
  token: "",
});

const usageStatsWithDate = await turso.databases.usage("my-db");

const usageStatsWithDate = await turso.databases.usage("my-db", {
  from: new Date("2023-01-01"),
  to: new Date("2023-02-01"),
});

const usageStatsWithString = await turso.databases.usage("my-db", {
  from: "2023-01-01T00:00:00Z",
  to: "2023-02-01T00:00:00Z",
});

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Path Parameters

organizationSlug
string
required

The slug of the organization or user account.

databaseName
string
required

The name of the database.

Query Parameters

from
string<date-time>

The datetime to retrieve usage from in ISO 8601 format. Defaults to the current calendar month if not provided. Example: 2023-01-01T00:00:00Z

to
string<date-time>

The datetime to retrieve usage to in ISO 8601 format. Defaults to the current calendar month if not provided. Example: 2023-02-01T00:00:00Z

Response

Successful response

database
object

The database usage object, containg the total and individual instance usage for rows read and written, as well as the total storage size (in bytes).