Question

How to iterate paginated Contacts search results

  • 7 January 2022
  • 3 replies
  • 281 views

Request

POST https://api.intercom.io/contacts/search
Accept:
application/json
Content-Type: application/json
Intercom-Version: 2.4
Authorization: Bearer token
 
{
"query": {
"operator": "AND",
"value": [
{
"field": "email",
"operator": "~",
"value": "timur+1"
}
]
}
}

results in

{
"type": "list",
"data": [...],
"total_count": 78,
"pages": {
"type": "pages",
"next": {
"page": 2,
"starting_after": "Wy0xLCI1ZjIyYzQzZjkxMjU5NmY1MDNiMjA4ZWUiLDJd"
},
"page": 1,
"per_page": 50,
"total_pages": 2
}
}

But next request

POST https://api.intercom.io/contacts/search?starting_after=Wy0xLCI1ZjIyYzQzZjkxMjU5NmY1MDNiMjA4ZWUiLDJd
Accept:
application/json
Content-Type: application/json
Intercom-Version: 2.4
Authorization: Bearer token
 
{
"query": {
"operator": "AND",
"value": [
{
"field": "email",
"operator": "~",
"value": "timur+1"
}
]
}
}

returns first page again. How to retrieve second page?


3 replies

Google works better, yet =)

https://developers.intercom.com/intercom-api-reference/reference/pagination-search/p>

 

I'm just wondering, why this page can't be referenced from this paragraph? https://developers.intercom.com/intercom-api-reference/reference/search-for-contacts#response/p>

And why pagination interface can't be unique throughout the API?

Userlevel 4
Badge +5

Hey @timur​ 

 

Pagination has it's own section within our API, and we link to pagination in our list contacts endpoint, as this is where the pagination would occur. Definitely understand it can be tricky navigating around the API docs! As we mention here when listing any Contact objects, we will instead use a cursor-based approach, our Search resources will instead use a POST-based approach.

Reply