퀵스타트
퀵스타트 (Quickstart)
Turso Platform API를 몇 단계만에 시작하는 방법을 소개해요. 토큰 발급부터 그룹·데이터베이스 생성, 연결까지 차례로 따라가 보세요.
출처: 문서
본문
**TypeScript 사용 중이신가요?** 원시 HTTP 예제를 건너뛰고 [`@tursodatabase/api`](https://www.npmjs.com/package/@tursodatabase/api) 클라이언트를 바로 쓸 수도 있어요. [SDK 퀵스타트](https://docs.turso.tech/api-reference/introduction#quickstart-with-the-typescript-sdk)를 참고하세요. 아직이라면 먼저 [Turso CLI를 설치](https://docs.turso.tech/cli/installation)하세요.Get started with Turso API in a few easy steps.
<CodeGroup>
```bash Signup theme={null}
turso auth signup
```
```bash Login theme={null}
turso auth login
```
</CodeGroup>
Platform API는 개인 계정으로도, 조직으로도 사용할 수 있어요. Turso CLI로 계정이나 조직의 `slug`를 확인해 보세요:
```bash theme={null}
turso org list
```
이제 Turso CLI로 새 API 토큰을 만들어요:
```bash theme={null}
turso auth api-tokens mint quickstart
```
`--org` 옵션으로 특정 조직에 맞춰 토큰을 발급할 수도 있어요:
```bash theme={null}
turso auth api-tokens mint quickstart --org my-org
```
<Info>
토큰은 안전한 곳에 잘 저장해 두세요. 다음 단계에서 필요해요.
</Info>
특정 리전에 그룹이나 데이터베이스를 만들기 전에, 먼저 사용 가능한 리전 목록을 가져와야 해요:
<CodeGroup>
```bash cURL theme={null}
curl -L 'https://api.turso.tech/v1/locations' \
-H 'Authorization: Bearer ***' \
```
```ts Node.js theme={null}
import { createClient } from "@tursodatabase/api";
const turso = createClient({
org: "...",
token: "",
});
const locations = await turso.locations.list();
```
</CodeGroup>
<br />
<Info>
`organizationSlug`는 조직 이름 또는 개인 계정 이름이에요.
</Info>
모든 데이터베이스는 하나 이상의 위치에 존재하는 그룹에 속해요.
먼저 `name`과 기본 `location`을 지정해 그룹을 만들어요:
<CodeGroup>
```bash cURL theme={null}
curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/groups' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"name": "default",
"location": "lhr"
}'
```
```ts Node.js theme={null}
import { createClient } from "@tursodatabase/api";
const turso = createClient({
org: "...",
token: "",
});
const group = await turso.groups.addLocation("default", "lhr");
```
</CodeGroup>
이제 위에서 만든 그룹에 첫 데이터베이스를 만들어요:
<CodeGroup>
```bash cURL theme={null}
curl -L -X POST 'https://api.turso.tech/v1/organizations/{organizationSlug}/databases' \
-H 'Authorization: Bearer ***' \
-H 'Content-Type: application/json' \
-d '{
"name": "my-db",
"group": "default"
}'
```
```ts Node.js theme={null}
import { createClient } from "@tursodatabase/api";
const turso = createClient({
org: "...",
token: "",
});
const database = await turso.databases.create("my-db", "ams");
```
</CodeGroup>
이제 여러 리전에 분산된 데이터베이스가 준비됐어요. 공식 또는 실험용 SDK 중 하나를 골라 연결해 보세요:
<Snippet file="all-sdks.mdx" />