Retrieving List of Records
There are API endpoints available to retrieve a list of records. Some of the API endpoints, by default retrieve 100 or 500 records per response. If there are more records available, a __next link is available at the end of the response payload to navigate to the next set of records. The following is a snippet of response payload in JSON format with __next link.
{
"d": {
"results": [
{
...
},
...
{
...
}
],
"__next": "https://appiot-thing-group-ci.cfapps.sap.hana.ondemand.com/ThingGroup/v1/ThingGroup?$skiptoken=20"
}
}
The following is a snippet of response payload in XML format with __next link.
<entry>
...
</entry>
<entry>
...
</entry>
<link href="https://appiot-thing-group-ci.cfapps.sap.hana.ondemand.com/ThingGroup/v1/ThingGroup?$skiptoken=20" rel="next"></link>
However, with REST services, the response payload contains __next and __prev link. The following is a snippet of response payload in JSON format with __next and __prev links.
{
"value": [
{
...
},
...
{
...
}
],
"next": "https://appiot-mds-ci.cfapps.sap.hana.ondemand.com/Things?$skip=1000",
"prev": "https://appiot-mds-ci.cfapps.sap.hana.ondemand.com/Things?$skip=0"
}
To retrieve a list of records, we recommend you avoid using $count with every service request. Instead, use $top and $skip in the service request, thereby reducing the server load.
For example, assume you have configured 1000 thing types. You want to retrieve thing types using the application config-thing-sap. This application, by default retrieves 500 records per response and displays the __next link in the response payload.
-
If you try retrieving 750 thing types using the URL /ThingConfiguration/v1/ThingTypes?$top=750, the service retrieves first 500 records along with the __next link in the response payload. You can use the __next link to retrieve the next 250 records and repeat calling the service request until all records are retrieved, if there are any.
-
If you try retrieving 10 thing types using the URL /ThingConfiguration/v1/ThingTypes?$top=10, the service retries 10 thing types and the __next link will not be displayed in the response payload.