Skip to content

Relation Paging

API operations described above provide a way to retrieve a limited (initial) set of related data. In most real world scenarios, there may be more related objects than returned by Single Step, Two Step or Relation Depth Retrieval APIs. To obtain a complete set of related objects Backendless supports Relation Paging API described below.

Important

  1. To understand the concept of paged data retrieval, see the Data retrieval with Paging section of the documentation.
    2. When working with paging, it may be important to know the total size of the related collection. See the Get Object Count section for details on how to get the related objects count.

Methods

GET

URL

https://api.backendless.com/<application-id>/<REST-api-key>/data/<table-name>/<parentObjectId>/<relationName>?pageSize=<pageSize>&offset=<offset> 

where:

Argument                Description
<application-id> the ID of your application generated upon its creation. You can obtain the value in the Manage > App Settings section of the Backendless Console.
<REST-api-key> REST API key of your application. You can obtain the value in the Manage > App Settings section of the Backendless Console.
<table-name> name of the table which contains the parent object identified by <parentObjectId>.
<parentObjectId> id of the object for which the related objects will be retrieved.
<relationName> name of the column which identifies the relation in the parent table (shown in the URL as <table-name>). This is the relation for which the related data will be retrieved.
<pageSize> sets the page size which is the number of objects to be returned in the response.
<offset> zero-based index of the object in the persistent store from which to start object retrieval. Suppose the first request returned 10 related objects and there are 100 objects total. The subsequent request can set offsetto 20, so the next batch of objects is loaded sequentially.

Request Headers

user-token: value-of-the-user-token-header-from-login

where:

Argument                Description
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-tokenis set in the request, the currently logged in user will be assigned to the ownerId property of the user object which is being saved. Additionally, the operation will be executed with the security policy associated currently logged in user. This means all permissions associated with the user and the roles assigned to the user will be enforced by Backendless.

Request Body

None

Return Value

Array of related objects or error.

Example

The example below includes two API requests to load separate "pages" or related data. The first page includes 20 data objects from offset  0 and the second page loads another 20 objects from offset 20. The data is loaded for the orderItem relation declared in the Order table.

Load page 1:

curl "https://api.backendless.com/<application-id>/<REST-api-key>/data/Order/<parentObjectId>/orderItem?pageSize=20&offset=0" 

Load page 2:

curl "https://api.backendless.com/<application-id>/<REST-api-key>/data/Order/<parentObjectId>/orderItem?pageSize=20&offset=20"