Skip to main content

How pagination works

The API has list and search endpoints that can return multiple objects, such as listing campaigns or searching for results. To mitigate negative impacts to performance, these endpoints don’t return all results at once. Instead, the API returns one page of results per API call, with each page containing up to 10 results by default. Use the limit parameter to change the number of results per page. For example, this is an API request to list campaigns results that uses role based evaluations, with a limit of 3:
curl -G https://api.external.hirednow.ai/v1/campaigns/role/results \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -d campaign_id=320009f5-eb09-4a58-94a8-aad39e6ddd14 \
  -d limit=3

The response from the API contains one page with 3 results:
{
  "data": [
    {
      "id": "aa430250-883a-46be-98ce-a978847740a6",
      "campaign_id": "320009f5-eb09-4a58-94a8-aad39e6ddd14",
      "user_id": "1c493040-b756-4aea-a043-54d9c2dd1857",
      ...
      "order_index": 100
    },
    {
      "id": "0265ea37-d286-4395-b9d0-f0d21b9ad634",
      "campaign_id": "320009f5-eb09-4a58-94a8-aad39e6ddd14",
      "user_id": "3e19b1dc-d32d-49e2-82c6-260fb81996c3",
      ...
      "order_index": 101
    },
    {
      "id": "9c0a3ed8-44ee-47f1-a497-c1ccd2893711",
      "campaign_id": "320009f5-eb09-4a58-94a8-aad39e6ddd14",
      "user_id": "0d1fea0f-6415-42f2-a92d-bdb82b0fe4fd",
      ...
      "order_index": 105
    }
  ],
  "has_more": true,
  "last_record_id": 105
}
Keep in mind the following details when using these endpoints:
  • Objects are inside the data property.
  • Objects are sorted by created_at in descending order (newest first) by default.
  • The has_more property indicates if there are additional objects that weren’t returned in this request.

Follow these steps to paginate results

  1. Make an API call to list the objects that you want to find.
curl https://api.external.hirednow.ai/v1/campaigns/role/results \
  -H "Authorization: Bearer <YOUR_API_KEY>"\
  -d campaign_id=320009f5-eb09-4a58-94a8-aad39e6ddd14
  1. In the response, check the value of has_more:
    • If the value is false, you’ve retrieved all the objects.
    • If the value is true, get the ID from last_record_id, and make a new API call with the starting_after parameter set to that ID.
Repeat this step until you’ve retrieved all of the objects that you want to find.
curl -G https://api.external.hirednow.ai/v1/campaigns \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -d campaign_id=320009f5-eb09-4a58-94a8-aad39e6ddd14 \
  -d starting_after=105

Parameters

limit
integer
default:"10"
A limit on the number of objects to be returned. Limit can range between 1 and 100, and the default is 10.
starting_after
string
A cursor for use in pagination. starting_after is an object ID that defines your place in the list. For instance, if you make a list request and receive 10 objects, ending with ID 105, your subsequent call can include starting_after=105 in order to fetch the next page of the list.

Response format

All paginated endpoints return responses in the following format:
{
  "data": [...],
  "has_more": true,
  "last_record_id": 105
}
data
array
Array of objects for the current page
has_more
boolean
Whether there are more objects available after this page
last_record_id
string
ID of the last record in the current page. Use this as the starting_after parameter for the next page. null if there are no more pages.