Cursor Based Pagination For Search APIs

From 202401 version and above, we have moved from index based pagination to cursor based pagination for our search APIs for the following endpoints:

  • adAccounts
  • adCampaignGroups
  • adCampaigns
  • adCreatives

API calls that return a large number of entities are broken up into multiple pages of results. You might need to make multiple API calls with slightly varied paging parameters to iteratively collect all the data you are trying to gather.

Parameters

Name Description Default
pageSize Specifies the number of entities to be returned. The default is 100. 100
pageToken Unique key used to fetch the next set of entities. nextPageToken is returned in metadata field of the search response. This should be passed in pageToken query parameter in the request to get the next page of results.

To paginate through results, begin with a pageSize value of N and no pageToken. To get the next set of results, set pageToken value to the nextPageToken returned in the previous response, while the pageSize value stays the same.

Sample Request

GET https://api.linkedin.com/v2/{service}?pageSize=10

Sample Response

{
  "metadata": {
    "nextPageToken": "DgGerr1iVQreCJVjZDOW_grcp63nueBDipsS4DJpvJo"
  },
  "elements": [
    {"Result #0"},
    {"Result #1"},
    {"Result #2"},
    {"Result #3"},
    {"Result #4"},
    {"Result #5"},
    {"Result #6"},
    {"Result #7"},
    {"Result #8"},
    {"Result #9"}
  ]
}

API Call to get the next set of results would use the nextPageToken returned in the response above.

Sample Request

GET https://api.linkedin.com/v2/{service}?pageSize=10&pageToken=DgGerr1iVQreCJVjZDOW_grcp63nueBDipsS4DJpvJo

End of the Dataset

When the response does not contain a nextPageToken, it indicates that you have reached the end of the dataset.