# Pagination: Base Company API

## Overview

General information about the pagination is listed in [Results Pagination](https://docs.coresignal.com/api-introduction/requests/elasticsearch-dsl/results-pagination) topic.

Here you can find:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><a href="#using-pagination-in-curl-requests">Using pagination in cURL requests</a></td><td>Examples of pagination usage with cURL requests.</td></tr></tbody></table>

## Using pagination in cURL requests

{% hint style="info" %}
This tutorial requires prior knowledge of how to compile and execute POST requests in Base Company API.
{% endhint %}

Use parameter `x-next-page-after` to retrieve a second page of IDs.

1. Navigate to the **Headers** section and click it:

![](https://archbee-image-uploads.s3.amazonaws.com/iNaodsHbfav9t72Jx5JdM/Xh3fndrpyjUGXyoMs7qm2_image.png)

2. Find the following information:\
   – `x-next-page-after`\
   \
   \
   \
   \
   – `x-total-pages`\
   \
   – `x-total-results`
3. Add parameter `?after={x-next-page-after}` to the POST request to see the next results page
4. Execute the request, and you will see the next page in the **Body** section:

```json
[
1000,
1001,
3000,
4004
]
```

### Pagination using sorting

<table data-view="cards"><thead><tr><th></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td>Sorting in Elasticsearch DSL</td><td><a href="..#sorting-options">#sorting-options</a></td></tr></tbody></table>

**Pagination usage example (cURL request in Postman)**

1. Add parameter `?after={x-next-page-after}` to the POST request:\
   Refer to the example below for the exact parameter placement:

{% code title="Pagination (sorted by id)" %}

```json
curl -X 'POST' \
'https://api.coresignal.com/cdapi/v2/company_base/search/es_dsl?after=33468751' \
  -H 'accept: application/json' \
  -H 'apikey: {API Key}' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": {
        "bool": {
            "must": [
                {
                    "query_string": {
                        "query": "(3D printing) OR (3D printing service) OR (Lead generation)",
                        "default_field": "description",
                        "default_operator": "and"
                    }
                }
            ]
        }
    },
  "sort": [
        "id"
    ]
}'
```

{% endcode %}

**Send** the request, and you will see the next page in the **(Response) Body**.

***

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

![](https://archbee-image-uploads.s3.amazonaws.com/iNaodsHbfav9t72Jx5JdM/5rrFXOBP5x7dYJDcu7jGT_image.png)

**Pagination usage example (cURL request in Postman)**

Add parameter `?after={x-next-page-after}` to the POST request to see the next results page. Refer to the example below for the exact parameter placement:

{% code title="Pagination (sorted by score)" %}

```json
curl -X 'POST' \
'https://api.coresignal.com/cdapi/v2/company_base/search/es_dsl?after=28.772884,"2025-03-09 21:49:52",89757124' \
  -H 'accept: application/json' \
  -H 'apikey: {API Key}' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": {
        "bool": {
            "must": [
                {
                    "query_string": {
                        "query": "(3D printing) OR (3D printing service) OR (Lead generation)",
                        "default_field": "description",
                        "default_operator": "and"
                    }
                }
            ]
        }
    },
  "sort": [
        "_score"
    ]
}'
```

{% endcode %}

**Send** the request, and you will see the next page in the **(Response) Body**.

## 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.

{% code title="Items per page" %}

```json
curl -X 'POST' \
'https://api.coresignal.com/cdapi/v2/company_base/search/es_dsl?items_per_page=100' \
  -H 'accept: application/json' \
  -H 'apikey: {API Key}' \
  -H 'Content-Type: application/json' \
  -d '{
    "query": {
        "bool": {
            "must": [
                {
                    "query_string": {
                        "query": "(3D printing) OR (3D printing service) OR (Lead generation)",
                        "default_field": "description",
                        "default_operator": "and"
                    }
                }
            ]
        }
    }
}'
```

{% endcode %}
