Product
Publishers
Advertisers
Networks
Help
Pause animations
Browse help topics
How-to PublisherNetwork

Paging and sorting a large list

Updated

View as Markdown

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.

See also: Offer API

On this page

Steps

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

  2. Walk the pages

    JavaScript
    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;
    }
  3. Choose an order

    sortOrders by
    payoutWhat the whole offer pays you (effectivePayoutUsd)
    install_payoutWhat the install pays you. Offers that don’t pay at install count as $0.
    first_event_payoutThe first step that pays you, in the order the row lists its steps. A one-payout offer sorts by that payout.
    epcEarnings per click at your payout (networkEpc)
    conversion_rateThe same as epc, which stands in for it
    newestWhen the offer started running
    popularWhat the offer earned across AffiliateOS in the last 30 days. Pair it with segment=popular.
    featuredFeatured 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.

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

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.

Support

Still stuck? Write to us.

One address for every question: hello@affiliateos.ai. Put the details from this list in your first message so we can find the click or conversion without asking you for them again.

Put these in your message

  1. 01The email you sign in with
  2. 02Your role: publisher, advertiser or network
  3. 03The offer ID
  4. 04The click ID or action_id
  5. 05The time it happened, with your time zone
  6. 06What you expected to happen

Looking for a reward in an app? Ask that app's support. It credits your reward, so only it can see your balance.

Search help