Skip to content
中文

Quickstart

Run this example in Node.js 22 or later with your API Key in the PRAXIS_API_KEY environment variable. It creates a new database on each run.

终端窗口
npm install @supabase/supabase-js

Save the following as quickstart.mjs and run node quickstart.mjs.

import { createClient } from "@supabase/supabase-js";
const api = "https://api.deepraxis.com";
const key = process.env.PRAXIS_API_KEY;
if (!key) throw new Error("Set PRAXIS_API_KEY");
async function request(path, method, body) {
const response = await fetch(`${api}/database/v1${path}`, {
method,
headers: {
Authorization: `Bearer ${key}`,
"Content-Type": "application/json",
},
...(body === undefined ? {} : { body: JSON.stringify(body) }),
});
const result = await response.json();
if (!response.ok) throw new Error(`${response.status}: ${result.message}`);
return result;
}
const database = await request("/table", "POST", {
name: "Agent tasks",
labels: { purpose: "docs" },
});
await request(`/table/${database.id}/tables`, "POST", {
name: "tasks",
fields: [
{ name: "title", type: "string", required: true, unique: true },
{ name: "done", type: "boolean" },
],
});
const supabase = createClient(`${api}/supabase/${database.id}/`, key, {
auth: { persistSession: false, autoRefreshToken: false },
});
const inserted = await supabase.from("tasks")
.insert({ title: "Write a summary", done: false }).select();
if (inserted.error) throw inserted.error;
const selected = await supabase.from("tasks")
.select("*").order("title").limit(10);
if (selected.error) throw selected.error;
console.log({ database_id: database.id, rows: selected.data });

The output includes database_id and the row you inserted. Keep the database ID for subsequent calls. The trailing slash in the Supabase URL is required.

Row operations → · Concepts →

When finished, delete this example database with the following request. The database recovery window is described in Concepts.

终端窗口
curl -X DELETE "https://api.deepraxis.com/database/v1/table/${DATABASE_ID}" \
-H "Authorization: Bearer $PRAXIS_API_KEY"

Set DATABASE_ID to the ID printed by the example.

Build one in the Console

  1. Open Console → 数据库 (Databases) (/database) and click “新建数据库” (New database).
  2. Open the database, click “新建表” (New table), then define each column with “添加字段” (Add field).

Next steps