Skip to content

Latest commit

 

History

History
159 lines (103 loc) · 2.81 KB

quickstart.mdx

File metadata and controls

159 lines (103 loc) · 2.81 KB
title description
Quickstart
Get started with Turso API in a few easy steps.

Make sure to install the Turso CLI if you haven't already.

turso auth signup
turso auth login

The Platform API can be used with your personal account or with an organization. You'll need the obtain the slug of your account or organization using using the Turso CLI:

turso org list

Now create a new API Token using the Turso CLI:

turso auth api-tokens mint quickstart

Make sure to save the token somewhere safe. We'll need it next.

Before we can create a group or database in a specific region, we'll need to fetch the list of available regions:

curl -L 'https://api.turso.tech/v1/locations' \
  -H 'Authorization: Bearer TOKEN' \
import { createClient } from "@tursodatabase/api";

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

const locations = await turso.locations.list();

The organizationSlug is the name of your organization or personal account.

All databases belong to a group that can exist in one or more locations.

Begin by creating a group, giving it a name and primary location:

curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/groups' \
  -H 'Authorization: Bearer TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
      "name": "default",
      "location": "lhr"
  }'
import { createClient } from "@tursodatabase/api";

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

const group = await turso.groups.addLocation("default", "lhr");

Now create your first database in the group you created above:

curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases' \
  -H 'Authorization: Bearer TOKEN' \
  -H 'Content-Type: application/json' \
  -d '{
      "name": "my-db",
      "group": "default"
  }'
import { createClient } from "@tursodatabase/api";

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

const database = await turso.databases.create("my-db", "ams");

You now have a database, distributed across multiple regions that you can connect to using one of the official or experimental SDKs: