> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hub2.io/llms.txt
> Use this file to discover all available pages before exploring further.

# List payments

Retrieving lists of payments can be done using the dedicated endpoint.

[List payments](/api-reference/payments/retrieve-a-payments-collection)

## Request

Here is a sample of a request to that endpoint:

<CodeGroup>
  ```bash Curl theme={null}
  curl --location --request GET 'https://api.hub2.io/payments?from=2023-01-01T00:00:00.000Z&to=2023-01-01T12:00:00.000Z&page=1&perPage=100' \
  --header 'ApiKey: [REDACTED]' \
  --header 'MerchantId: [REDACTED]' \
  --header 'Environment: sandbox' \
  --header 'Content-Type: application/json' \
  ```

  ```typescript Typescript theme={null}
  import fetch from 'node-fetch';

  async function getPayments() {
      const response = await fetch('https://api.hub2.io/payments?from=2023-01-01T00:00:00.000Z&to=2023-01-01T12:00:00.000Z&page=1&perPage=100', {
          method: 'GET',
          headers: {
              'ApiKey': '[REDACTED]',
              'MerchantId': '[REDACTED]',
              'Environment': 'sandbox',
              'Content-Type': 'application/json'
          }
      });

      if (response.ok) {
          const result = await response.json();
          console.log(result);
      } else {
          console.log(`HTTP Status: ${response.status}`);
      }
  }

  getPayments();
  ```

  ```python Python theme={null}
  import requests

  url = 'https://api.hub2.io/payments?from=2023-01-01T00:00:00.000Z&to=2023-01-01T12:00:00.000Z&page=1&perPage=100'

  headers = {
      'ApiKey': '[REDACTED]',
      'MerchantId': '[REDACTED]',
      'Environment': 'sandbox',
      'Content-Type': 'application/json',
  }

  response = requests.get(url, headers=headers)

  if response.status_code == 200:
      print(response.json())
  else:
      print(f'HTTP Status: {response.status_code}')
  ```
</CodeGroup>

Please note the following parameters:

* Parameter `from` : identify the starting date of the range for wish to fetch payments, the value here is `2023-01-01T00:00:00.000Z`
* Parameter `to` : identify the ending date of the range for wish to fetch payments, the value here is `2023-01-01T12:00:00.000Z`
* Parameters `page` and `perPage` : allow you to navigate in the result pages

<Warning>
  **In case of high traffic, it cannot be expected to retrieve all payments without using pagination.**
</Warning>

### Pagination

Pagination is available on that endpoint.

<Note>
  A header is provided in the response to identify the number of results., it's the `Content-Range` header and its content looks like `0-99/2453`.
</Note>

In that particular case, the first 100 results are fetched on a 2453 total - there is 25 pages of 100 results available.

Don't forget to use date filters too to avoid the number of results changing between two requests.

## Response

<Note>
  Results are automatically ordered by the created date in a descending order.
</Note>

Here is a sample of the response in JSON format:

```json theme={null}
[
    {
        "id": "pi_HVSUvR5OvvyZn4ozGonNs",
        "createdAt": "2023-11-06T11:52:18.139Z",
        "updatedAt": "2023-11-06T11:52:26.382Z",
        "merchantId": "wP8PsNc3Je3Djp2FTiQTO",
        "purchaseReference": "purchaseReference",
        "customerReference": "customerReference",
        "amount": 10,
        "currency": "XOF",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbnRlbnRJZCI6InBpX0hWU1V2UjVPdnZ5Wm40b3pHb25OcyIsIm1lcmNoYW50SWQiOiJ3UDhQc05jM0plM0RqcDJGVGlRVE8iLCJtb2RlIjoic2FuZGJveCIsImlhdCI6MTY5OTI3MTUzOH0.Bg2PIujWvtGIlH1jSPRndUiyBD8WBNRuWUQ242GHCZ8",
        "status": "successful",
        "payments": [
            {
                "id": "pay_vhmS6bGBsTCP08rXOAFZJ",
                "intentId": "pi_HVSUvR5OvvyZn4ozGonNs",
                "createdAt": "2023-11-06T11:52:18.891Z",
                "updatedAt": "2023-11-06T11:52:26.402Z",
                "amount": 10,
                "currency": "XOF",
                "status": "successful",
                "method": "mobile_money",
                "country": "CI",
                "provider": "orange",
                "number": "00000001",
                "fees": []
            }
        ],
        "mode": "sandbox"
    },
    {
        "id": "pi_-RSGf4F7vqyPxfv2fYGpp",
        "createdAt": "2023-11-06T11:52:17.914Z",
        "updatedAt": "2023-11-06T11:52:25.978Z",
        "merchantId": "wP8PsNc3Je3Djp2FTiQTO",
        "purchaseReference": "purchaseReference",
        "customerReference": "customerReference",
        "amount": 10,
        "currency": "XOF",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbnRlbnRJZCI6InBpXy1SU0dmNEY3dnF5UHhmdjJmWUdwcCIsIm1lcmNoYW50SWQiOiJ3UDhQc05jM0plM0RqcDJGVGlRVE8iLCJtb2RlIjoic2FuZGJveCIsImlhdCI6MTY5OTI3MTUzN30.4XX1HeDk_Be_sEvaBcqx6GfxBB2qrFJu7btHVUyLZII",
        "status": "successful",
        "payments": [
            {
                "id": "pay_uEBdIHJLwytg6phBvhg3d",
                "intentId": "pi_-RSGf4F7vqyPxfv2fYGpp",
                "createdAt": "2023-11-06T11:52:18.605Z",
                "updatedAt": "2023-11-06T11:52:25.986Z",
                "amount": 10,
                "currency": "XOF",
                "status": "successful",
                "method": "mobile_money",
                "country": "CI",
                "provider": "orange",
                "number": "00000001",
                "fees": []
            }
        ],
        "mode": "sandbox"
    },
    {
        "id": "pi_UcRWisVdLCCw2Bq5S7XRl",
        "createdAt": "2023-11-06T11:52:17.677Z",
        "updatedAt": "2023-11-06T11:52:25.665Z",
        "merchantId": "wP8PsNc3Je3Djp2FTiQTO",
        "purchaseReference": "purchaseReference",
        "customerReference": "customerReference",
        "amount": 10,
        "currency": "XOF",
        "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpbnRlbnRJZCI6InBpX1VjUldpc1ZkTENDdzJCcTVTN1hSbCIsIm1lcmNoYW50SWQiOiJ3UDhQc05jM0plM0RqcDJGVGlRVE8iLCJtb2RlIjoic2FuZGJveCIsImlhdCI6MTY5OTI3MTUzN30.zOPnbV8pRL0LVWPtU_m2bdW5-KIKBkTfffGbiEOvhKY",
        "status": "successful",
        "payments": [
            {
                "id": "pay_GdhjiFTsMcT4aeXrmK6xJ",
                "intentId": "pi_UcRWisVdLCCw2Bq5S7XRl",
                "createdAt": "2023-11-06T11:52:18.352Z",
                "updatedAt": "2023-11-06T11:52:25.668Z",
                "amount": 10,
                "currency": "XOF",
                "status": "successful",
                "method": "mobile_money",
                "country": "CI",
                "provider": "orange",
                "number": "00000001",
                "fees": []
            }
        ],
        "mode": "sandbox"
    }
]
```
