API 端點
GET /schema — 列出資料表與欄位
回傳 LLM 撰寫合法 data 所需的一切資訊。
GET /api/public/v1/schema
Authorization: Bearer <token>
回應 200:
{
"tables": [
{
"id": "uuid",
"name": "quiz_results",
"description": "…",
"columns": [
{ "id": "uuid", "name": "score", "type": "number", "order_index": 0 }
]
}
]
}
POST /tables — 建立資料表
POST /api/public/v1/tables
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "quiz_results",
"description": "應用內測驗提交資料",
"columns": [
{ "name": "student_id", "type": "text" },
{ "name": "score", "type": "number" },
{ "name": "submitted_at","type": "date" }
]
}
回應 201:{ "id": "…", "name": "quiz_results", ... }
POST /tables/{table}/columns — 新增欄位
{table} 為資料表名稱。
POST /api/public/v1/tables/quiz_results/columns
{
"columns": [
{ "name": "class_name", "type": "text" },
{ "name": "percentage", "type": "number" }
]
}
GET /tables/{table}/rows — 取得資料列
Query 參數:?limit=100&offset=0(預設 100、0)。
GET /api/public/v1/tables/quiz_results/rows?limit=50
{
"rows": [
{ "id": "uuid", "data": { "student_id": "S001", "score": 87 }, "created_at": "..." }
]
}
POST /tables/{table}/rows — 插入一筆或多筆
插入單筆:
{ "data": { "student_id": "S001", "score": 87 } }
批次插入(單次上限 500 筆):
{ "rows": [ { "student_id": "S001", "score": 87 }, { "student_id": "S002", "score": 92 } ] }
觸發 webhook 事件 row.created。
GET /rows/{id} — 取得單筆資料列
GET /api/public/v1/rows/<row-uuid>
PATCH /rows/{id} — 更新資料列
預設為合併(只覆寫提供的欄位):
{ "data": { "score": 90 } }
完整取代:{ "data": {...}, "merge": false }。
DELETE /rows/{id} — 刪除資料列
回傳 { "ok": true }。
GET /people — 列出 people
{ "people": [ { "id": "...", "full_name": "...", "email": "...", "student_id": "...", "extra": {} } ] }
POST /people — Upsert people
matchKey 決定去重依據:student_id(預設)或 email。
{
"matchKey": "email",
"people": [
{ "full_name": "Ada Lovelace", "email": "ada@example.com", "class_name": "S1A", "student_id": "S001" }
]
}
或單筆:{ "person": { ... } }。觸發 webhook people.upserted。
GET /people/me — 查詢目前終端使用者
GET /api/public/v1/people/me?email=ada@example.com
GET /api/public/v1/people/me?auth_user_id=<uuid>
POST /relationships — 建立欄位關聯
{
"from_table": "quiz_results",
"from_column": "student_id",
"to_table": "people",
"to_column": "student_id",
"kind": "many_to_many"
}
kind ∈ one_to_one | one_to_many | many_to_many。