Overview

The Violet APIs provide you with access to immense amounts of data. Through pagination, you can easily navigate through this data using the page and size query parameters.

Requests

Query Parameters:

page

The starting position for which this API should return data.

size

Limit to the number of items returned by this request. Default value of 20 if field not set.

Curl
curl -X POST https://sandbox-api.violet.io/v1/<pagination_enabled_API>?page=1&size=20 \
-H "X-Violet-App-Id: your-app-id-here" \
-H "X-Violet-App-Secret: your-app-secret-here" \
-H "X-Violet-Token: your-token-here" \

Response

Responses for calls that support pagination include additional information designed to let you quickly navigate through our datasets. The following information is returned:

content

Content you are requesting from the call.

pageable

Custom object that stores information about details for the current page, such as page number, sort, etc.

total_elements

Total number of elements matching query criteria.

last

Boolean denoting whether or not this is the last page.

total_pages

Total number of pages based on size input from query parameter.

sort

Sorting details for ordering returned in content.

number_of_elements

Number of elements present in current page.

first

Boolean denoting whether or not this is the first page.

size
Input size from query parameter.
number
TBD.
empty

Boolean denoting whether or not content is present.

JSON
{
    "content": [ ... ],
    "pageable": {
        "sort": {
            "unsorted": true,
            "sorted": false,
            "empty": true
        },
        "page_number": 0,
        "page_size": 1,
        "offset": 0,
        "paged": true,
        "unpaged": false
    },
    "total_elements": 133,
    "last": false,
    "total_pages": 133,
    "sort": {
        "unsorted": true,
        "sorted": false,
        "empty": true
    },
    "number_of_elements": 1,
    "first": true,
    "size": 1,
    "number": 0,
    "empty": false
}

As seen above, Violet uses page and total_elements in the response object to give you details on the total number of elements present in our datasets matching your criteria as well as the number of total pages you need to go through for all data. You can pass these page numbers through the request query parameters to fetch the next set of data.

Since Violet uses more than next and previous cursors to let you traverse through the dataset, you can even use page numbers and size to make parallel calls to our system to retrieve information as quickly as you need to for your application.

Was this page helpful?