Skip to Content

Documentation

Risk Cloud API: Pagination

The Risk Cloud API contains a variety of endpoints that may return a substantial amount of listed data. These endpoints utilize a style of offset pagination to provide a means of processing the data in smaller portions.

Page Requests

Risk Cloud API endpoints that support Pagination accept two optional query parameters to indicate what portion of data to return.

  • page – an integer representing the zero-indexed page number (must not be lessthan 0, defaults to 0)
  • size – an integer representing the size of the page and maximum number of items to be returned (must not be less than 1, defaults to 20)

These query parameters function conceptually similar to how pages are implemented in the Risk Cloud UI, where the page is the page number value, albeit zero-indexed, and size is the Results per page value.

Example

The Field Read All endpoint of GET /api/v1/fields utilizes Pagination. If there are 50 active Fields (numbered 1-50) in a Risk Cloud environment, then the following query parameters will return the following Fields.

PageSizeRequestFields
None (Default 0)None (Default 20)GET /api/v1/fields1-20
020GET /api/v1/fields?page=0&size=201-20
120GET /api/v1/fields?page=1&size=2021-40
220GET /api/v1/fields?page=2&size=2041-50
08GET /api/v1/fields?page=0&size=81-8
18GET /api/v1/fields?page=1&size=89-16

Page Responses

When a Risk Cloud API endpoint returns a Page, the response body contains a variety of properties. 

PropertyTypeDescription
contentarrayA list of the returned items
numberintegerThe zero-indexed page number
sizeintegerThe size of the page and maximum number of items to be returned
totalElementsintegerThe total number of items available
totalPagesintegerThe total number of pages available based on the size
firstbooleanWhether the current page is the first one
lastbooleanWhether the current page is the last one
emptybooleanWhether the current page is empty
numberOfElementsintegerThe number of items currently on this page
sortobjectThe sorting parameters for the page
sort.emptybooleanWhether the current page is empty
sort.sortedbooleanWhether the page items are sorted
sort.unsortedbooleanWhether the page items are not sorted

Page Processing

Depending on the integration, there are multiple strategies for processing data from a Risk Cloud API endpoint that supports Pagination.

  • Bulk
  • Iteration

Bulk

The Bulk strategy involves sending a single request to obtain a bulk result. This is accomplished by providing a large value for the size query parameter. The size value should be large enough to surpass the expected maximum amount of possible returned items. An example would be: GET /api/v1/fields?size=1000

The items can then be obtained from the content property of the response.

Pseudocode Example

CALL GetFields with size as 1000 RETURNING response 
SET items to response.content

Iteration

The Iteration strategy involves sending multiple requests and assembling a result. This can be accomplished in multiple ways, including the following.

  • Incrementing the page number until a response where last is true is received
  • Incrementing the page number until it reaches the amount of the totalPages response property

Pseudocode Example

SET items to [] 
SET index to 0 
REPEAT 
  CALL GetFields with page as index RETURNING response 
  APPEND response.content to items 
  INCREMENT index 
UNTIL response.last = true