# Results Pagination

### Why is pagination needed?

Results containing IDs are provided in batches of 1,000 IDs per page.

Sometimes, a request might yield more IDs than can be displayed on a single page. In such situations, you'll need to use pagination to obtain all the requested IDs from the POST request.

### Where can I see the page count?

<details>

<summary>Response headers in Swagger UI</summary>

Navigate to the *Responses* section and locate the *Response headers*.![](https://archbee-image-uploads.s3.amazonaws.com/iNaodsHbfav9t72Jx5JdM/r3cwat-YnsMCO4VJvVLZ3_authorization.png)

</details>

### Response header information

Response headers contain information such as **the total result count**, **page number**, and **the last ID** on the page:

* `x-next-page-after` – displays the last ID on the page. This field contains `last_updated` and `ID` information. Here `last_updated` format differs between entities.
* `x-total-pages` – lists the total number of pages with ID results.
* `x-total-results` – shows the total number of IDs returned by your search.

An example of Multi-source Company API response headers:

```json
x-next-page-after: "2025-03-03",3771705 
x-total-pages: 57 
x-total-results: 56940 
```

### Sorting in pagination

Pagination using **ID** sorting works the same way as pagination without sorting.

Pagination using **score** sorting has a different ID format. The format difference is seen by the `x-next-page-after` parameter, where results show: the **score**, the **last updated** date, and the **last ID** on the page.

An example of Multi-source Company API response headers:

{% code title="Sorting by score" %}

```json
x-next-page-after: 26.806067,"2025-02-25",6428995 
x-total-pages: 57 
x-total-results: 56940 
```

{% endcode %}

### Using pagination in cURL requests

Add a parameter `?after={x-next-page-after}` to the POST request to see the next results page. Example of Multi-source Company request:

```json
curl -X 'POST' \
'https://api.coresignal.com/cdapi/v2/company_multi_source/search/es_dsl?after="2025-03-03",3771705' \
  -H 'accept: application/json' \
  -H 'apikey: {API Key}' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": {}, //Insert your query
}'
```

### Limiting search results per page

Query parameter `?items_per_page={int}` allows you to specify the number of results retrieved per Search results page. The current limit is 1,000. Thus, this parameter lets you set a smaller limit value for the results page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.coresignal.com/api-introduction/requests/elasticsearch-dsl/results-pagination.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
