データベースレコードの取得
データベースレコードの取得
このAPIインターフェースを使うことで、指定したデータテーブルからページ分割されたレコードデータを取得できます。
リクエストメソッド
POST
エンドポイント
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"
}'
このコードブロックをポップアップで表示
リクエストヘッダー
| フィールド | タイプ | 説明 |
|---|---|---|
| Authorization | Bearer ${API Key} | 認証には Authorization: Bearer ${API Key} を使用してください。トークンはAPIキーページから取得できます。 |
| Content-Type | application/json | リクエストボディの形式を指定します。 |
リクエストボディ
| フィールド | タイプ | 必須 | 説明 |
|---|---|---|---|
| table_id | String | 必須 | テーブルのIDを指定します。 |
| page | Int | 必須 | 取得したいページ番号(1から開始)を指定します。 |
| page_size | Int | 必須 | 1ページあたりのレコード数(1〜100の範囲)を指定します。 |
| filter | Object | 任意 | ユーザー定義のフィルター条件は、"unique": true を含むフィールドが必要で、1つのフィールドのみサポートされます。 |
| ) | |||
| keyword | String | 任意 | キーワード(あいまい検索対応) |
レスポンス
レスポンス例
{
"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 | データID |
| records[].value | Object | データの値 |
| records[].created_at | Long | 作成された時間 |
| records[].updated_at | Long | 更新された時間 |
| table_info | Object | データテーブルの情報 |
テーブル情報の属性
| フィールド | タイプ | 説明 |
|---|---|---|
| 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 | エージェントのID |
| project_id | String | プロジェクトのID |
| owner_id | String | データテーブルの所有者ID |
エラー時のレスポンス
| フィールド | タイプ | 説明 |
|---|---|---|
| code | Int | エラーコード |
| message | String | エラーの詳細情報 |
エラーコード
| Code | Message |
|---|---|
| 40000 | パラメータエラー |
| 40127 | 開発者認証に失敗しました |
| 403106 | テーブルが見つかりません |
| 403131 | データテーブルにアクセスする権限がありません |
| 50000 | システム内部エラー |
