Pagination

Fetching all objects of a resource can be convenient. At the same time, returning too many objects at once can be impractical from a performance perspective. Doing so might be too much work for the Mollie API to generate, or for your website to process. The maximum number of objects returned is 250.

For this reason the Mollie API only returns a subset of the requested set of objects. In other words, the Mollie API chops the result of a certain API method call into pages you are able to programmatically scroll through.

Pagination in v2 API endpoints

The v2 API endpoints use the so-called cursor pagination method. In short, this ensures the objects in a page do not get shifted when a new object is created with the same account in the meantime, by paginating by object ID rather than by page number.

Some endpoints have support for the sort parameter to indicate the direction of the results. Set this parameter to desc for older or asc for newer objects. The default is desc.

You can get the next page of objects by following the next link.

Response object

count integer

The number of objects found in _embedded, which is either the requested number (with a maximum of 250) or the default number.

_embedded object

The actual data you are looking for.

_links object

Links to help navigate through the lists of objects. Every URL object will contain an href and a type field.

Example of v2 pagination

Request

curl -X GET https://api.mollie.com/v2/payments \
    -H "Authorization: Bearer test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM"
<?php
$mollie = new \Mollie\Api\MollieApiClient();
$mollie->setApiKey("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM");

// get the first page
$payments = $mollie->payments->page();

// get the next page
if($payments->hasNext()) {
    $next_payments = $payments->next();
}

// get the previous page
if($payments->hasPrevious()) {
    $previous_payments = $payments->previous();
}
from mollie.api.client import Client

mollie_client = Client()
mollie_client.set_api_key("test_dHar4XY7LxsDOtmnkVtjNVWXLSlXsM")

# Get the first page
payments = mollie_client.payments.list()

# Get the next page
if payments.has_next():
  next_payments = payments.get_next()

# Get the previous page
if payments.has_previous():
  previous_payments = payments.get_previous()
We don't have a Ruby code example for this API call yet.

If you have some time to spare, feel free to share suggestions on our Discord:
https://discord.gg/mollie
We don't have a Node.js code example for this API call yet.

If you have some time to spare, feel free to share suggestions on our Discord:
https://discord.gg/mollie

Response

HTTP/1.1 200 OK
Content-Type: application/hal+json

{
    "count": 10,
    "_embedded": {
        "payments": [
            {
                "resource": "payment",
                "id": "tr_7UhSN1zuXS",
                "mode": "test",
                "createdAt": "2018-02-12T11:58:35.0Z",
                "expiresAt": "2018-02-12T12:13:35.0Z",
                "status": "open",
                "isCancelable": false,
                "amount": {
                    "value": "75.00",
                    "currency": "GBP"
                },
                "description": "test",
                "method": "ideal",
                "metadata": null,
                "details": null,
                "profileId": "pfl_QkEhN94Ba",
                "redirectUrl": "https://webshop.example.org/order/12345/",
                "_links": {
                    "checkout": {
                        "href": "https://www.mollie.com/paymentscreen/issuer/select/ideal/7UhSN1zuXS",
                        "type": "text/html"
                    },
                    "self": {
                        "href": "https://api.mollie.com/v2/payments/tr_7UhSN1zuXS",
                        "type": "application/hal+json"
                    },
                    "documentation": {
                        "href": "https://docs.mollie.com/reference/v2/payments-api/get-payment",
                        "type": "text/html"
                    }
                }
            },
            { },
            { }
        ]
    },
    "_links": {
        "self": {
            "href": "https://api.mollie.com/v2/payments?limit=10",
            "type": "application/hal+json"
        },
        "previous": null,
        "next": {
            "href": "https://api.mollie.com/v2/payments?from=tr_SDkzMggpvx&limit=10",
            "type": "application/hal+json"
        },
        "documentation": {
            "href": "https://docs.mollie.com/reference/v2/payments-api/list-payments",
            "type": "text/html"
        }
    }
}