Pagination
Pagination lowers the API response times, which increases performance of the application for large data sets.
If large amounts of data are being retrieved, your API call could time out after 30 seconds. To prevent this from occuring, we recommend using pagination in the query parameters of your API call.
The pagination parameters include the:
count
- the total number of results retrievedlimit
- the maximum number of results to retrieveoffset
- the number of results to omit
You can set the limit
and offset
for certain API calls in the calls' query parameters. For calls that use pagination,
the count
, limit
, and offset
are returned in the response as metadata.
The following are API calls for which pagination can be used:
GET /devices/{imei}/events
GET /organizations/{orgId}/devices
POST /organizations/{orgId}/events
The following is an example of an API request with pagination:
curl --request POST https://api-prod.surfsight.net/v2/organizations/{organizationId}/events
--header 'Content-Type: application/json'
--header 'Authorization: Bearer {token}'
--data-raw '{
"offset": 10
"limit": 1
"start": 2021-12-24T09:50:07.485Z
"end": 2021-12-27T09:50:07.485Z
"eventTypes": ["acceleration","button"]
}'
The following is an example of an API response with pagination:
{
"data": [
{
"id": 3,
"eventType": "acceleration",
"time": "2020-01-01T14:48:00.000Z",
"lat": 32.0598671,
"lon": 34.7827316,
"speed": 22.51,
"accuracy": 4,
"status": "new",
"severity": 1,
"eventComments": [
{
"id": 125,
"comment": "string",
"createdByAudienceName": "surfsight",
"createdById": 625,
"createdBy": {
"id": 32,
"email": "email@email.com"
},
"createdAt": "2021-12-27T10:33:43Z"
}
],
"files": [
{
"cameraId": 1,
"fileType": "video",
"fileId": "1595077872"
}
],
"geoFenceId": 3,
"metadata": "{type:'Test event', scope:'Some test scope'}"
}
],
"metadata": {
"count": 15,
"limit": 1,
"offset": 10
}
}