メインコンテンツへスキップ

Documentation Index

Fetch the complete documentation index at: https://docs.qoder.com/llms.txt

Use this file to discover all available pages before exploring further.

概要

Qoder Cloud Agents API のリスト型エンドポイントは カーソルページネーション(Cursor-based Pagination)を採用しています。before_idafter_id パラメータでデータウィンドウを指定し、データ変動時のページング結果の安定性を確保します。

リクエストパラメータ

パラメータ必須デフォルト値説明
limitintegerいいえ201 ページあたりの返却件数。範囲は 1-100
before_idstringいいえこの ID より前のレコードを返す(前へページング)
after_idstringいいえこの ID より後のレコードを返す(次へページング)
before_idafter_id を同時に使用することはできません。両方を渡すと 400 invalid_request_error が返されます。

レスポンス構造

すべてのリスト型エンドポイントは統一されたページングエンベロープを返します。
{
  "data": [
    { "id": "agent_abc123", "name": "my-agent", "..." : "..." },
    { "id": "agent_def456", "name": "another-agent", "..." : "..." }
  ],
  "first_id": "agent_abc123",
  "last_id": "agent_def456",
  "has_more": true
}

フィールド説明

フィールド説明
dataarray現在のページのリソースリスト
first_idstring | null現在のページの最初のレコードの ID
last_idstring | null現在のページの最後のレコードの ID
has_morebooleanさらにデータがあるかどうか

基本的な使い方

最初のページの取得

# 最初の 10 件の Agent を取得 \
curl -s "https://openapi.qoder.sh/api/v1/cloud/agents?limit=10" \
  -H "Authorization: Bearer $QODER_PAT"

次へページング

前ページレスポンスの last_idafter_id として使用します。
# agent_def456 より後の 10 件のレコードを取得 \
curl -s "https://openapi.qoder.sh/api/v1/cloud/agents?limit=10&after_id=agent_def456" \
  -H "Authorization: Bearer $QODER_PAT"

前へページング

現在のページの first_idbefore_id として使用します。
# agent_abc123 より前の 10 件のレコードを取得 \
curl -s "https://openapi.qoder.sh/api/v1/cloud/agents?limit=10&before_id=agent_abc123" \
  -H "Authorization: Bearer $QODER_PAT"

完全なトラバース例

以下のスクリプトはすべての Agent をトラバースします。
#!/bin/bash
# すべての Agent をトラバースして名前を表示
BASE_URL="https://openapi.qoder.sh/api/v1/cloud"
has_more=true
after_id=""
page=1

while [ "$has_more" = "true" ]; do
  # URL を構築
  url="$BASE_URL/agents?limit=50"
  if [ -n "$after_id" ]; then
    url="$url&after_id=$after_id"
  fi

  # リクエストを発行
  response=$(curl -s "$url" \
    -H "Authorization: Bearer $QODER_PAT")

  # レスポンスを解析
  count=$(echo "$response" | python3 -c "import sys,json; d=json.load(sys.stdin); print(len(d['data']))")
  has_more=$(echo "$response" | python3 -c "import sys,json; print(str(json.load(sys.stdin)['has_more']).lower())")
  after_id=$(echo "$response" | python3 -c "import sys,json; print(json.load(sys.stdin)['last_id'] or '')")

  echo "${page} ページ目: ${count} 件のレコードを取得"

  # 現在のページのデータを処理
  echo "$response" | python3 -c "
import sys, json
data = json.load(sys.stdin)['data']
for item in data:
    print(f\"  - {item['id']}: {item.get('name', 'unnamed')}\")
"

  page=$((page + 1))

  # リクエスト間隔、過剰な速度を回避
  sleep 0.1
done

echo "トラバース完了"

limit パラメータの説明

動作
渡さないデフォルトで 20 件返す
1最小値、1 件返す
100最大値、100 件返す
0 または負数400 エラーを返す
> 100400 エラーを返す
# 1 件のみ取得、データ存在の確認に使用 \
curl -s "https://openapi.qoder.sh/api/v1/cloud/agents?limit=1" \
  -H "Authorization: Bearer $QODER_PAT"

空の結果

データがない、または末尾に到達した場合:
{
  "data": [],
  "first_id": null,
  "last_id": null,
  "has_more": false
}

注意事項

  1. カーソルの安定性 — カーソルはリソース ID に基づくため、期間中に新規データが書き込まれても重複や欠落は発生しません。
  2. ソート方向 — デフォルトで作成時刻の降順(最新が先頭)。
  3. 削除済みリソース — 削除済みのリソース ID をカーソルとして使用した場合、400 エラーが返される可能性があります。
  4. 並行安全性 — 複数のクライアント間で並行してページングしても安全です。