> AffiliateOS Help Center. Index of every article for AI tools: https://www.affiliateos.ai/help/llms.txt

# Paging and sorting a large list

Offers and the feed · For publishers, networks · Updated 30 October 2026
Web version: https://www.affiliateos.ai/help/offers/paging-and-sorting

Paging is off until you send `page` or `per_page`: without them, one response holds every offer. Send `per_page` (up to 200) and walk `page` from 1 until `has_more_pages` is `false`. Add `sort` and `sort_dir` to choose the order.

## Steps

### Pick a page size

Send `per_page` with a number from 1 to 200. If you send only `page`, pages hold 50 offers. Pages count from 1.

### Walk the pages

```js
const all = [];
for (let page = 1; ; page += 1) {
  const url = new URL("https://affiliateos.xyz/publisher/offers");
  url.search = new URLSearchParams({
    country: "US",
    sort: "payout",
    page: String(page),
    per_page: "200",
  });
  const res = await fetch(url, {
    headers: { "x-api-key": process.env.AFFILIATEOS_KEY },
  });
  const { data } = await res.json();
  all.push(...data.offers);
  if (!data.pagination.has_more_pages) break;
}
```

### Choose an order

| `sort` | Orders by |
|---|---|
| `payout` | What the whole offer pays you (`effectivePayoutUsd`) |
| `install_payout` | What the install pays you. Offers that don't pay at install count as $0. |
| `first_event_payout` | The first step that pays you, in the order the row lists its steps. A one-payout offer sorts by that payout. |
| `epc` | Earnings per click at your payout (`networkEpc`) |
| `conversion_rate` | The same as `epc`, which stands in for it |
| `newest` | When the offer started running |
| `popular` | What the offer earned across AffiliateOS in the last 30 days. Pair it with `segment=popular`. |
| `featured` | Featured offers first |

`sort_dir=asc` sorts low to high. Leave it out, or send `desc`, for high to low. Without `sort`, rows come in no particular order.

### Check it worked

Every response carries `pagination`: `current_page`, `per_page`, `total` (rows across every page) and `has_more_pages`. A page past the end returns an empty `offers` array, not an error. This route has no `next_page` field; count up from 1 instead.

## Keep a full list in step

- **Each page is worked out when you ask for it.** If an offer fills its cap or comes back while you're paging, rows can shift between pages. Collect rows by `id` and drop repeats, and finish a pass in one go.
- **Swap in a new list only after a full pass.** If a page fails, keep the list you had and try the pass again later.
- **Need everything once?** Skip paging. Without `page` and `per_page`, one response holds every offer, and `total` equals the number of rows.
- **`segment=top` keeps its own order.** The Top Offers Feed ignores `sort`; paging keeps the order it arrives in. See [Get our top offers in order](https://www.affiliateos.ai/help/offers/get-top-offers-in-order).

## On the Offers page

The **All** tab lists 50 offers a page, with **Previous**, **Next** and "Page 1 of" the page count. Its sort menu has **Sort: Most popular**, **Sort: Total payout** (the default), **Sort: Install payout**, **Sort: First event payout** and **Sort: Newest**. Category pages open in our recommended order (**Sort: Recommended**) and can sort by the three payouts. Accounts paid per step don't get **Sort: Install payout**.

Your page, sort and filters stay in the page's address, so opening an offer and going back keeps your place, and you can share the link with a teammate.

## For networks

The Network API (`/network-api/offers`) pages by default: 50 offers a page unless you send `per_page`. Its `pagination` has `current_page`, `per_page`, `has_more_pages` and `next_page` (`null` on the last page), but no `total`. Follow `next_page` until it's `null`. The same `sort` values work there, except `install_payout`: Network API rows don't carry an install payout, so that sort leaves the order unchanged.

In the network dashboard, **Offers** lists 10 offers a page, and **Sort by payout** orders them **High to Low** or **Low to High**.
