Paging and sorting a large list
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
Pick a page size
Send
per_pagewith a number from 1 to 200. If you send onlypage, pages hold 50 offers. Pages count from 1.Walk the pages
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
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 itnewestWhen 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=ascsorts low to high. Leave it out, or senddesc, for high to low. Withoutsort, rows come in no particular order.Check it worked
Every response carries
pagination:current_page,per_page,total(rows across every page) andhas_more_pages. A page past the end returns an emptyoffersarray, not an error. This route has nonext_pagefield; count up from 1 instead.
- 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
idand 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
pageandper_page, one response holds every offer, andtotalequals the number of rows. segment=topkeeps its own order. The Top Offers Feed ignoressort; paging keeps the order it arrives in. See Get our top offers in order.
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.
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.