⚠️ This SDK is still in development and is not ready for production use.
import { createClient } from "@tursodatabase/api";
const turso = createClient({
org: "", // Your personal account or organization slug
token: "...",
});
const organizations = await turso.organizations.list();
const orgMembers = await turso.organizations.update({ overages: true });
const orgMembers = await turso.organizations.delete();
const orgMembers = await turso.organizations.members();
const orgMembers = await turso.organizations.addMember("username", "admin");
const orgMembers = await turso.organizations.removeMember("username");
const orgMembers = await turso.organizations.inviteUser(
"jamie@turso.tech",
"admin"
);
const locations = await turso.locations.list();
const closest = await turso.locations.closest();
const groups = await turso.groups.list();
const group = await turso.groups.get("default");
const group = await turso.groups.create("customgroup", "lhr");
const group = await turso.groups.create("customgroup", "ams", {
extensions: "all", // or ["uuid", "vector"]
});
const group = await turso.groups.delete("customgroup");
const group = await turso.groups.addLocation("default", "lhr");
const group = await turso.groups.removeLocation("default", "lhr");
const token = await turso.groups.createToken("default");
const token = await turso.groups.createToken("default", {
expiration: "1w2d6h3n",
authorization: "full-access",
});
const token = await turso.groups.rotateTokens("default");
const tokens = await turso.apiTokens.list();
const token = await turso.apiTokens.create("superdupertokenname");
const token = await turso.apiTokens.revoke("superdupertokenname");
const token = await turso.apiTokens.validate("token");
const database = await turso.databases.list();
const database = await turso.databases.get("my-db");
const database = await turso.databases.create("db-name");
const database = await turso.databases.create("db-name", {
image: "canary",
group: "my-group",
});
const database = await turso.databases.create("db-name", {
group: "my-group",
seed: {
type: "database",
name: "my-existing-db",
},
});
const database = await turso.databases.create("db-name", {
group: "my-group",
seed: {
type: "database",
name: "my-existing-db",
timestamp: "2021-01-01T00:00:00Z", // or new Date("2021-01-01T00:00:00Z")
},
});
const database = await turso.databases.updateVersion("my-db");
const database = await turso.databases.delete("my-db");
const instances = await turso.databases.listInstances("my-db");
const instances = await turso.databases.getInstance("my-db", "lhr");
const token = await turso.databases.createToken("my-db");
const token = await turso.databases.createToken("my-db", {
expiration: "1w2d6h3n",
authorization: "full-access",
});
const token = await turso.databases.rotateTokens("my-db");
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"),
});
// Using ISOStrings
const usageStatsWithString = await turso.databases.usage("my-db", {
from: "2023-01-01T00:00:00Z",
to: "2023-02-01T00:00:00Z",
});
- Maybe change to named args for all methods