ดึงข้อมูลเรคคอร์ดจากฐานข้อมูล

ดึงข้อมูลเรคคอร์ดจากฐานข้อมูล

API นี้รองรับการส่งคำขอเพื่อดึงข้อมูลเรคคอร์ดแบบแบ่งหน้าจากตารางข้อมูลที่ระบุ

วิธีการร้องขอ

POST

Endpoint

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

การยืนยันตัวตน

ดูรายละเอียดวิธีการยืนยันตัวตนได้ที่ API Overview

คำขอ

ตัวอย่างการร้องขอ

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"
}'

                    
บล็อกโค้ดนี้ในหน้าต่างลอย

Request Headers

ฟิลด์ ประเภท คำอธิบาย
Authorization Bearer ${API Key} ใช้ Authorization: Bearer ${API Key} สำหรับการยืนยันตัวตน รับ API Key ได้จากหน้า API Key
Content-Type application/json ประเภทข้อมูล ต้องเป็น application/json

Request Body

ฟิลด์ ประเภท จำเป็น คำอธิบาย
table_id string ใช่ รหัสตารางข้อมูล
page int ใช่ หมายเลขหน้า เริ่มต้นที่ 1
page_size int ใช่ จำนวนเรคคอร์ดต่อหน้า ช่วง 1-100
filter map ไม่ เงื่อนไขการกรองที่ผู้ใช้กำหนด ต้องมีฟิลด์ที่ "unique": true และรองรับเพียง 1 ฟิลด์เท่านั้น
keyword string ไม่ คำค้น รองรับการค้นหาแบบ fuzzy

การตอบกลับ

ตัวอย่างการตอบกลับ

{ "table_info": { "id": "673e9c7a9f7bc178002dbce8", "name": "test_api", "description": "Test all database APIs", "field_count": 5, "fields": [ { "name": "id", "description": "id", "type": "TEXT", "required": true, "unique": true }, { "name": "boolean", "description": "boolean", "type": "BOOLEAN", "required": true, "unique": false }, { "name": "int", "description": "int", "type": "INT", "required": true, "unique": true }, { "name": "datetime", "description": "datetime", "type": "DATETIME", "required": true, "unique": false }, { "name": "float", "description": "float", "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": "Test all database APIs",
            "field_count": 5,
            "fields": [
                {
                    "name": "id",
                    "description": "id",
                    "type": "TEXT",
                    "required": true,
                    "unique": true
                },
                {
                    "name": "boolean",
                    "description": "boolean",
                    "type": "BOOLEAN",
                    "required": true,
                    "unique": false
                },
                {
                    "name": "int",
                    "description": "int",
                    "type": "INT",
                    "required": true,
                    "unique": true
                },
                {
                    "name": "datetime",
                    "description": "datetime",
                    "type": "DATETIME",
                    "required": true,
                    "unique": false
                },
                {
                    "name": "float",
                    "description": "float",
                    "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 รหัสข้อมูล
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
project_id string รหัสโปรเจกต์
owner_id string รหัสเจ้าของตารางข้อมูล

การตอบกลับเมื่อผิดพลาด

ฟิลด์ ประเภท คำอธิบาย
code int รหัสข้อผิดพลาด
message string รายละเอียดข้อผิดพลาด

รหัสข้อผิดพลาด

รหัส ข้อความ
40000 พารามิเตอร์ไม่ถูกต้อง
40127 การยืนยันตัวตนของนักพัฒนาไม่สำเร็จ
403106 ไม่พบตารางข้อมูล
403131 ไม่มีสิทธิ์เข้าถึงตารางข้อมูล
50000 ข้อผิดพลาดภายในระบบ