> ## 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.

# Offset-based Pagination

export const MultiRelatedLinks = ({sections = []}) => {
  if (!sections || sections.length === 0) {
    return null;
  }
  return <div className="space-y-8">
      {sections.map((section, index) => <RelatedLinks key={index} title={section.title} items={section.items} />)}
    </div>;
};

export const RelatedLinks = ({title, items = []}) => {
  const getBadgeClass = badge => {
    if (!badge) return "badge-default";
    const badgeType = badge.toLowerCase().replace(/\s+/g, "-");
    return `badge-${badge === "ガイド" ? "guide" : badgeType}`;
  };
  if (!items || items.length === 0) {
    return null;
  }
  return <div className="my-8">
      {}
      <h3 className="text-sm font-bold uppercase tracking-wider mb-4">{title}</h3>

      {}
      <div className="flex flex-col gap-3">
        {items.map((item, index) => <a key={index} href={item.href} className="py-2 px-3 rounded related_link hover:bg-[#f2f2f2] dark:hover:bg-[#111827] flex items-center gap-3 group no-underline hover:no-underline border-b-0">
            {}
            <span className={`px-2 py-1 rounded-full text-xs font-semibold uppercase tracking-wide flex-shrink-0 ${getBadgeClass(item.badge)}`}>
              {item.badge}
            </span>

            {}
            <span className="text-base">{item.label}</span>
          </a>)}
      </div>
    </div>;
};

export const Link = ({href, children, className, ...props}) => {
  const localizedHref = href;
  return <a href={localizedHref} className={className} {...props}>
      {children}
    </a>;
};

APIs that use offset-based paging use the `offset` and `limit` query parameters
to paginate through items in a collection.

Offset-based pagination is often used where the list of items is of a fixed and
predetermined length.

## Paging

To fetch the first page of entries in a collection the API needs to be called
either without the `offset` parameter, or with the `offset` set to `0`. The
`limit` field is optional.

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

To fetch the next page of entries the API needs to be called with
an `offset` parameter that equals the sum of the previous `offset` value and
limit returned in the previous result, `previous_offset + previous_limit`.

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

<Note>
  Note that the `offset` should be increased by the previous `limit` and not by
  the size of the entries in the response array, as this may be less than the
  limit. Generally we advise using the value of the `limit` in the response
  object to increase the `offset` value.
</Note>

The final page of items has been requested when the next `offset` value exceeds
the `total_count` value in the response object. At this point there are no more
items to fetch.

## Offset & Limit

The following query parameters are used to paginate a collection.

| Query parameter | Type    | Default        |                                                                                                                      |
| --------------- | ------- | -------------- | -------------------------------------------------------------------------------------------------------------------- |
| `offset`        | Integer | `0`            | The (zero-based) offset of the first item returned in the collection. In a zero-based offset `0` is a correct value. |
| `limit`         | Integer | Depends on API | The maximum number of entries to return. If the value exceeds the maximum, then the maximum value will be used.      |

<Note>
  The maximum `offset` for offset-based pagination is `9999`. Marker-based
  pagination is recommended when a higher offset is needed.
</Note>

## Collections

When paginating collections, the API returns an object that contains the set of
results as an array, as well as some information about the current page of results.

| Field         | Type    |                                                                                                                                                                   |
| ------------- | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `entries`     | Array   | The page of items for this page. This will be an empty array if there are no results.                                                                             |
| `offset`      | Integer | The offset used for this page of results                                                                                                                          |
| `limit`       | Integer | The limit used for this page of results. This will be the same as the `limit` query parameter unless it exceeded the maximum value allowed for this API endpoint. |
| `total_count` | Integer | One greater than the offset of the last item in the entire collection. The total number of items in the collection may be less than `total_count`.                |

## Example endpoints

Some endpoints that support offset-based pagination are:

* <Link href="/reference/get-folders-id-items">List items for a folder</Link>
* <Link href="/reference/get-files-id-comments">List a file's comments</Link>
* <Link href="/reference/get-folders-trash-items">List all items in the trash</Link>

<RelatedLinks
  title="RELATED APIS"
  items={[
{ label: translate("List items in folder"), href: "/reference/get-folders-id-items", badge: "GET" },
{ label: translate("List all file versions"), href: "/reference/get-files-id-versions", badge: "GET" },
{ label: translate("List file comments"), href: "/reference/get-files-id-comments", badge: "GET" },
{ label: translate("List trashed items"), href: "/reference/get-folders-trash-items", badge: "GET" },
{ label: translate("Search for content"), href: "/reference/get-search", badge: "GET" },
{ label: translate("List enterprise users"), href: "/reference/get-users", badge: "GET" },
{ label: translate("List members of group"), href: "/reference/get-groups-id-memberships", badge: "GET" },
{ label: translate("List user's groups"), href: "/reference/get-users-id-memberships", badge: "GET" },
{ label: translate("List groups for enterprise"), href: "/reference/get-groups", badge: "GET" },
{ label: translate("List group collaborations"), href: "/reference/get-groups-id-collaborations", badge: "GET" },
{ label: translate("List pending collaborations"), href: "/reference/get-collaborations", badge: "GET" },
{ label: translate("List collection items"), href: "/reference/get-collections-id-items", badge: "GET" }
]}
/>

<RelatedLinks
  title="RELATED GUIDES"
  items={[
{ label: translate("Sorting responses"), href: "/guides/api-calls/sorting", badge: "GUIDE" },
{ label: translate("Marker-based Pagination"), href: "/guides/api-calls/pagination/marker-based", badge: "GUIDE" }
]}
/>
