logo
開發者文件
搜尋
獲取資料庫記錄

獲取資料庫記錄

此 API 介面支援發送請求,從指定的資料表中分頁獲取記錄資料。

請求方法

POST

端點

https://api-${endpoint}.gptbots.ai/v1/database/records/page

認證

有關詳細資訊,請您參閱 API 概覽 中的認證方法說明。

請求

請求範例

curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/database/records/page' \ -H 'Authorization: Bearer ${API Key}' \ -H 'Content-Type: application/json' \ -d '{ "table_id": "673d7d00ce119a7e9f47d152", "page": 1, "page_size": 10, "filter": { "int": 100 }, "keyword": "keyword" }'
                      
                      curl -X POST 'https://api-${endpoint}.gptbots.ai/v1/database/records/page' \
-H 'Authorization: Bearer ${API Key}' \
-H 'Content-Type: application/json' \
-d '{
    "table_id": "673d7d00ce119a7e9f47d152",
    "page": 1,
    "page_size": 10,
    "filter": { 
        "int": 100
    },
    "keyword": "keyword"
}'

                    
此代碼塊在浮窗中顯示

請求標頭

欄位 類型 描述
Authorization Bearer ${API Key} 您可以從 API Key 頁面獲取 API Key,並使用 Authorization: Bearer ${API Key} 進行認證。
Content-Type application/json 資料類型,值為 application/json。

請求內容

欄位 類型 必填 描述
table_id string 資料表 ID。
page int 頁碼,從 1 開始。
page_size int 每頁記錄數,範圍為 1-100。
filter map 使用者自訂的篩選條件,必須包含一個 "unique": true 的欄位,且僅支援一個欄位。
keyword string 關鍵字,支援模糊查詢。

回應

回應範例

{ "table_info": { "id": "673e9c7a9f7bc178002dbce8", "name": "test_api", "description": "測試所有資料庫 API", "field_count": 5, "fields": [ { "name": "id", "description": "id", "type": "TEXT", "required": true, "unique": true }, { "name": "boolean", "description": "布林值", "type": "BOOLEAN", "required": true, "unique": false }, { "name": "int", "description": "整數", "type": "INT", "required": true, "unique": true }, { "name": "datetime", "description": "日期時間", "type": "DATETIME", "required": true, "unique": false }, { "name": "float", "description": "浮點數", "type": "FLOAT", "required": false, "unique": false } ], "bot_id": "673e93aca7c4223becf6caf0", "project_id": "665465e2b5c78e6c7ab92d2b", "owner_id": "665465e2b5c78e6c7ab92d28" }, "records": [ { "id": "541278230707963208", "value": { "id": "1", "boolean": true, "int": 1, "datetime": "2029-10-01 12:00:00", "float": 2024.21 }, "created_at": 1732156566000, "updated_at": 1732156607000 } ], "total_count": 2 }
                      
                      {
    "table_info": {
        "id": "673e9c7a9f7bc178002dbce8",
        "name": "test_api",
        "description": "測試所有資料庫 API",
        "field_count": 5,
        "fields": [
            {
                "name": "id",
                "description": "id",
                "type": "TEXT",
                "required": true,
                "unique": true
            },
            {
                "name": "boolean",
                "description": "布林值",
                "type": "BOOLEAN",
                "required": true,
                "unique": false
            },
            {
                "name": "int",
                "description": "整數",
                "type": "INT",
                "required": true,
                "unique": true
            },
            {
                "name": "datetime",
                "description": "日期時間",
                "type": "DATETIME",
                "required": true,
                "unique": false
            },
            {
                "name": "float",
                "description": "浮點數",
                "type": "FLOAT",
                "required": false,
                "unique": false
            }
        ],
        "bot_id": "673e93aca7c4223becf6caf0",
        "project_id": "665465e2b5c78e6c7ab92d2b",
        "owner_id": "665465e2b5c78e6c7ab92d28"
    },
    "records": [
        {
            "id": "541278230707963208",
            "value": {
                "id": "1",
                "boolean": true,
                "int": 1,
                "datetime": "2029-10-01 12:00:00",
                "float": 2024.21
            },
            "created_at": 1732156566000,
            "updated_at": 1732156607000
        }
    ],
    "total_count": 2
}

                    
此代碼塊在浮窗中顯示

成功回應

欄位 類型 描述
code int 訊息類型代碼。
message string 訊息描述。
total_count int 記錄總數。
records array 資料記錄陣列。
records[].id string 資料 ID。
records[].value object 資料內容。
records[].created_at long 建立時間。
records[].updated_at long 更新時間。
table_info object 資料表相關資訊,包含以下屬性:

table_info 屬性

欄位 類型 描述
id string 資料表唯一識別碼。
name string 資料表名稱。
description string 資料表描述。
field_count int 欄位數量。
fields array 欄位陣列,包含每個欄位的詳細資訊。
fields[].name string 欄位名稱。
fields[].description string 欄位描述。
fields[].type string 資料型別,例如 TEXT、INT、FLOAT 等。
fields[].required boolean 是否為必填欄位。
fields[].unique boolean 是否為唯一欄位。
bot_id string Agent ID。
project_id string 專案 ID。
owner_id string 資料表擁有者 ID。

失敗回應

欄位 類型 描述
code int 錯誤代碼。
message string 錯誤詳情。

錯誤代碼

錯誤代碼 訊息
40000 無效參數
40127 開發者認證失敗
403106 找不到資料表
403131 無權存取該資料表
50000 系統內部錯誤