Pagination & Sorting

How to easily page through large datasets.

Most of Raisely's index endpoints support pagination and sorting.

Specifically, performing a GET request on /campaigns, /comments, /donations, /profiles, /posts, /subscriptions, or /users supports standard pagination and sorting.

When you request a collection that supports pagination, it will include additional information to help with pagination.

You can use the following query parameters to control pagination and sorting

Query ParameterDefault ValueDescription
limit100The maximum number of records to return in this request.
offset0The number of records to skip ahead by.
orderdescThe direction to order the sort column. Can be asc or desc.
sortcreatedAtSelects a column to order the results by.

Every paginated request includes a pagination object in the response, the pagintation object contains the following information about pagination.

Pagintation AttributeExampleDescription
limit10The maximum number of records returned in the request.
The same as the query parameter, or the default if it wasn't specified.
nextUrlhttps://api.raisely.dev/v3/campaigns/d1412500-3ef0-11e7-ba8f-00254ba2a4bb/profiles?sort=goal&order=desc&limit=5&offset=15The url of the next page of results. If you are on the last page of results, this will be false.
offset15The offset that was requested, or 0 if it was unspecified
pages5The total number of pages
prevUrlhttps://api.raisely.dev/v3/campaigns/d1412500-3ef0-11e7-ba8f-00254ba2a4bb/profiles?sort=goal&order=desc&limit=5&offset=5The url of the previous page of results. If you are on the first page of results this will be false.
total23The total number of records available.

Example

// Fetch profiles ordered by fundraising goal from highest to lowest
// 5 profiles per page, show the 3rd page.

let url = `https://api.raisely.com/v3/campaigns/${campaignUuid}/profiles`;
let query = '?sort=goal&order=desc&limit=5&offset=10';

let profiles = yield request({
  method: ‘GET’,
  url: url + query,
});

console.log(profiles);
// Will show something like ...
{
    data: [<5 profile objects>]
  pagination: {
    limit: 5,       // The maximum number of records you requested
    nextUrl: "https://api.raisely.com/...", // Url for the next page
    offset: 10, // The offset you requested
    pages: 5,       // The total number of pages
    prevUrl: "https://api.raisely.com/...", // Url for the previous page
    total: 22       // The total number of records available
  }
}