> ## Documentation Index
> Fetch the complete documentation index at: https://developer.box.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 検索結果のページネーション

検索APIでは、`offset`クエリパラメータと`limit`クエリパラメータを使用したオフセットベースのページネーションがサポートされます。マーカーベースのページネーションはサポートされません。

## APIによるページネーション

検索結果の最初のページを取得するには、APIを`offset`パラメータを指定せずに呼び出すか、`offset`を`0`に設定して呼び出す必要があります。`limit`フィールドは省略可能です。

```sh theme={null}
curl https://api.box.com/2.0/search?query=sales&offset=0&limit=100 \
    -H "authorization: Bearer ACCESS_TOKEN"
```

エントリの次のページを取得するには、以前の`offset`値と以前の結果で返された制限の合計 (`previous_offset + previous_limit`) と等しい`offset`パラメータを指定して、APIを呼び出す必要があります。

```sh theme={null}
curl https://api.box.com/2.0/search?query=sales&offset=100&limit=100 \
    -H "authorization: Bearer ACCESS_TOKEN"
```

<Note>
  `offset`は、レスポンス配列内のエントリのサイズではなく、以前の`limit`分だけ加算されますので注意してください。これは制限を下回る可能性があるためです。一般的には、レスポンスオブジェクトの`limit`の値を使用して`offset`値を加算することをお勧めします。
</Note>

次の`offset`値がレスポンスオブジェクト内の`total_count`値を超えている場合、項目の最終ページはリクエスト済みです。この時点では、これ以上取得する項目がありません。

<Card href={localizeLink("/guides/api-calls/pagination/offset-based")} arrow title="オフセットベースのページネーションの詳細を確認する" />

## SDKによるページネーション

Boxの各SDKには、APIによるページネーションのサポートが組み込まれています。以下のコードサンプルでは、検索APIでのページネーションの使用方法を示します。

<CodeGroup>
  ```java Java theme={null}
  long offsetValue = 0;
  long limitValue = 50;

  BoxSearch boxSearch = new BoxSearch(api);
  BoxSearchParameters searchParams = new BoxSearchParameters();
  searchParams.setQuery("sales");

  PartialCollection<BoxItem.Info> page1 = boxSearch.searchRange(offsetValue, limitValue, searchParams);

  offsetValue += 50;
  PartialCollection<BoxItem.Info> page2 = boxSearch.searchRange(offsetValue, limitValue, searchParams);
  ```

  ```csharp .NET theme={null}
  BoxCollection<BoxItem> page1 = await client.SearchManager
      .QueryAsync("sales", limit: 50);
  BoxCollection<BoxItem> page2 = await client.SearchManager
      .QueryAsync("sales", limit: 50, offset: 50);
  ```

  ```python Python theme={null}
  page1 = client.search().query(query='sales', limit=50)
  page2 = client.search().query(query='sales', limit=50, offset=50)
  ```

  ```js Node theme={null}
  const page1 = await client.search.query('sales', {
      limit: 50
  })
  const page2 = await client.search.query('sales'. {
      limit: 50,
      offset: 50
  })
  ```
</CodeGroup>
