Each resource type has an all() function that fetches all objects of that type that exist in your project. The full list of objects might contain a large number of items and so it is useful to fetch just a short section of the list at a time. The section that you fetch is known as a page and the technique of fetching a list one page at a time is known as pagination.

To fetch the first page of the list, call the all() function with a limit option to specify the maximum number of items you want the page to contain. The page size defaults to 10 items if you omit the limit option or set it to zero. You can also pass an order option with a value of asc or desc to sort the page into ascending or descending order of sequence (the order defaults to desc if you omit this option).

curl -X GET -G https://api.processout.com/customers \
    -u test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x:key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB \
    --data-urlencode limit=20 \
    --data-urlencode order=asc
var ProcessOut = require("processout");
var client = new ProcessOut(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x",
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB");

client.newCustomer().all({
    limit:      20,
    order:      "asc"
}).then(function(customers) {
    // Customers were fetched
}, function(err) {
    // An error occured
});
import processout
client = processout.ProcessOut(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", 
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB")

customers = client.new_customer().all({
    "limit":       20,
    "order":       "asc"
})
require "processout"
client = ProcessOut::Client.new(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", 
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB")

customers = client.customer.all(
    limit:       20,
    order:       "asc"
)
<?php
$client = new \ProcessOut\ProcessOut(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", 
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB");

$customers = $client->newCustomer()->all(array(
    "limit"      => 20,
    "order"      => "asc"
));
import "github.com/processout/processout-go"

var client = processout.New(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", 
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB",
)

customers, err := client.NewCustomer().All(processout.CustomerAllParameters{
    Options: &processout.Options{
        Limit:      20,
        Order:      "asc",
    },
})

To fetch pages after the first, you use cursor-based pagination. This fetches a page of items relative to an item that you specify, which is called the cursor. The page contains the items that come either before or after the cursor (at your choice) but it does not include the cursor itself. For example, to fetch the second page, pass the id of the last item in the first page to all() using the start_after option. If you want the fetch the items that come before the cursor, then pass its id as the end_before option. Note that you cannot supply both start_after and end_before in the same call.

curl -X GET -G https://api.processout.com/customers \
    -u test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x:key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB \
    --data-urlencode start_after=cust_FM5ZDn3PjkCmDVXYnqrZFrnlypilDicD \
    --data-urlencode limit=20 \
    --data-urlencode order=asc
var ProcessOut = require("processout");
var client = new ProcessOut(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x",
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB");

client.newCustomer().all({
    startAfter: "cust_FM5ZDn3PjkCmDVXYnqrZFrnlypilDicD",
    limit:      20,
    order:      "asc"
}).then(function(customers) {
    // Customers were fetched
}, function(err) {
    // An error occured
});
import processout
client = processout.ProcessOut(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", 
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB")

customers = client.new_customer().all({
    "start_after": "cust_FM5ZDn3PjkCmDVXYnqrZFrnlypilDicD",
    "limit":       20,
    "order":       "asc"
})
require "processout"
client = ProcessOut::Client.new(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", 
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB")

customers = client.customer.all(
    start_after: "cust_FM5ZDn3PjkCmDVXYnqrZFrnlypilDicD",
    limit:       20,
    order:       "asc"
)
<?php
$client = new \ProcessOut\ProcessOut(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", 
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB");

$customers = $client->newCustomer()->all(array(
    "startAfter" => "cust_FM5ZDn3PjkCmDVXYnqrZFrnlypilDicD",
    "limit"      => 20,
    "order"      => "asc"
));
import "github.com/processout/processout-go"

var client = processout.New(
    "test-proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x", 
    "key_sandbox_mah31RDFqcDxmaS7MvhDbJfDJvjtsFTB",
)

customers, err := client.NewCustomer().All(processout.CustomerAllParameters{
    Options: &processout.Options{
        StartAfter: "cust_FM5ZDn3PjkCmDVXYnqrZFrnlypilDicD",
        Limit:      20,
        Order:      "asc",
    },
})

Note that the object returned by all() contains the page of items in an array named after the item type (for example, customers for a list of Customer objects). It also has a few other useful data
fields:

  • count: The number of items in the page (which is not necessarily the same as the limit value that you specify).
  • has_more: This is false when you use start_after and the page contains the last item in the list or when you use end_before and the page contains the first item. If you are working through the pages in sequence then this value essentially means that you have not reached the end of the list yet.
  • total_count: This gives the total number of items that matched your query. You can call all() with a limit value of 1 and ignore the page array if you only want to find the total_count for the list.
{
    "count": 10,
    "customers": [
        {
            "id": "cust_1g4YXoiOPBkCnsedpOmUS6wfmJaxtAAZ",
            "project_id": "proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x",
            "tokens": null,
            .
            .
        },
        {
            "id": "cust_jXpiWXv7yYbKeYZzyQifEDSHYzuElQxr",
            "project_id": "proj_gAO1Uu0ysZJvDuUpOGPkUBeE3pGalk3x",
            "tokens": null,
            .
            .
        },
        .
        .
    ],
    "has_more": true,
    "limit": 10,
    "order": "asc",
    "success": true,
    "total_count": 642
}