Adsly.pro
Documentation pages All documentation

Pagination

How to walk through every campaign of large cabinets with cursor pagination, and when the older offset mode is still fine.

View as Markdown

GET /v1/campaigns is the only list that pages. It has two modes.

Cursor mode (use this)

Add cursor= (empty on the first call) and follow meta.next_cursor until it is null:

curl -s "https://app.adsly.pro/api/v1/campaigns?limit=500&cursor=" -H "X-API-Key: $ADSLY_API_KEY"
{
  "success": true,
  "data": [ { "ad_id": 90412, "account_id": 53, "…": "…" } ],
  "meta": { "limit": 500, "cursor": null, "next_cursor": "eyJhIjo1MywiaSI6OTAzMTB9", "hasMore": true }
}
def all_campaigns():
    cursor = ""
    while True:
        r = requests.get("https://app.adsly.pro/api/v1/campaigns",
                         params={"limit": 500, "cursor": cursor},
                         headers={"X-API-Key": API_KEY}, timeout=60).json()
        yield from r["data"]
        cursor = r["meta"]["next_cursor"]
        if not cursor:
            break
  • Treat the cursor as opaque. It is only valid with the same filters.
  • Order is fixed (cabinet, then newest ad_id first), so pages stay stable while campaigns are added.
  • No upper limit — this is how you read a cabinet with 100,000 campaigns.
  • Filters bot_username, promote_domain and type always use cursor mode.
  • Cursor mode leaves out a few heavy fields (targeting summary, media, last action). Use GET /v1/campaigns/{ad_id} for the full record of one campaign.

Offset mode (small cabinets)

Without cursor, the endpoint pages with limit and offset and can sort (sortBy, sortOrder). It reads at most 500 campaigns per cabinet: past that meta.truncated is true and meta.next_step tells you to switch to cursor mode.

"meta": { "total": 1240, "limit": 100, "offset": 0, "hasMore": true, "truncated": true,
          "next_step": "Use ?cursor= for full traversal beyond 500 campaigns per cabinet" }

Page size

limit is 1–500, default 100.

Updated 2026-10-08

Discuss your project