Guides
API principles

Pagination

The three pagination styles of the Marketing API, by cursor, by index and none, and which route uses each.

The Marketing API paginates differently depending on the resource. Each route uses the style LinkedIn documents for it.

StyleParametersResponseRoutes
CursorpageSize (default 100, max 1000; creatives 100), pageTokenmetadata.nextPageToken, absent on the last pageadAccounts, adCampaignGroups and adCampaigns with q=search; creatives with q=criteria
Indexstart (default 0), count (default 10)paging {start, count, links, total}adAccountUsers, leadForms, leadFormResponses, leadNotifications, conversions, campaignConversions, adTargetingEntities, organizationAcls
NoneConstant pagingadAnalytics, audienceCounts, adBudgetPricing

By cursor

bash
curl -s 'https://linkedin-ads.mimicr.dev/rest/adAccounts/521119150/adCampaigns?q=search&search=(status:(values:List(ACTIVE,DRAFT)))&pageSize=2' \
  --header 'Authorization: Bearer <token>' --header 'LinkedIn-Version: 202610' --header 'X-Restli-Protocol-Version: 2.0.0'
json
{
  "elements": [
    { "id": 347373377, "name": "Gás residencial", "status": "ACTIVE" },
    { "id": 347365458, "name": "Gás para empresas", "status": "DRAFT" }
  ],
  "metadata": { "nextPageToken": "eyJsYXN0SWQiOjM0NzM2NTQ1OH0" }
}

Repeat the same search with &pageToken=eyJsYXN0SWQiOjM0NzM2NTQ1OH0 until metadata comes without nextPageToken. The token is opaque and bound to the filters: using it with other filters answers 400 "Invalid pageToken" (Mimicr's rule). sortOrder=ASCENDING|DESCENDING orders by id.

A campaign search that would return more than 1,000 without pageSize answers 400 "Request would return too many entities."

By index

bash
curl -s 'https://linkedin-ads.mimicr.dev/rest/leadFormResponses?q=owner&owner=(sponsoredAccount:urn%3Ali%3AsponsoredAccount%3A521119150)&leadType=(leadType:SPONSORED)&start=0&count=10' \
  --header 'Authorization: Bearer <token>' --header 'LinkedIn-Version: 202610' --header 'X-Restli-Protocol-Version: 2.0.0'
json
{ "elements": [ { "id": "4aa37137-8262-48cb-9736-964d6cf642fe-2", "leadType": "SPONSORED" } ], "paging": { "start": 0, "count": 10, "links": [], "total": 1 } }

Move start forward by count until it passes total. links is always empty. count over 1000 answers 400 "Specified count is larger than 1000"; for leads the maximum is 100.

No pagination

adAnalytics returns everything at once (up to 15,000 rows per response): paging is always {"start": 0, "count": 10, "links": []}, whatever the size. For fewer rows, shorten the range, use a coarser timeGranularity or filter by facets. See adAnalytics.