About data pagination

Learn how Toky API pagination works when an end point returns lots of data

Some end points allows data pagination to avoid timeout errors when loading lots of data. Some of these endpoints are:

Request parameters

The pagination is controlled by these parameters:

ParameterDescriptionData type
limitThe maximum rows that will come from every request.
Max value 500.
Integer
offsetIt's the starting row to get in the request.
Starts with 0.
Integer

📘

Example

Limit = 100 & offset = 0

It means that the end point requested will return maximum 100 rows starting from the record 0.

Response

The common response has these basic elements:

  • count: Number of rows returned. The limit parameter sent in the request is the maximum value.
  • next: This is the URL you can use to fetch the next page. It has the same limit parameter but the offset changes automatically to get the next page of data.
  • results: This element contains a JSON array with the requested data.

🚧

If the next element is null, this means you are getting the last page of data

{
"count": 20,
"next": "https://api.toky.co/v1/cdrs?offset=20&limit=20",
"results": [
  {
    "id": "12903",
    "callid": "3482582a-dc6e-1235-798c-0401336adf01",
    "from": "+551234567",
    "to_number": null,
    "country": "US",
    "caller_id_used": "+12018155555",
    "init_dt": "2017-07-05 21:46:44",
    "start_time": "2017-07-05 21:46:22",
    "end_time": "2017-07-05 21:46:44",
    "duration": "22",
    "agent_id": "carlos__myagent.com",
    "direction": "inbound",
    "web_call": "no",
    "disposition_code": "200",
    "ivr_option_pressed": "8"
    },
    ...
    
}