As you already discovered in the response to the request 03.01 Vessels, the number of items that is retrieved in the payload is limited to 25. The pagination uses $top and $skip query options to select the next set of data. We recommend including the $orderby method on properties with distinct values as part of the request, so that pagination is consistent. In addition, we recommend including $count=true so that the next link is provided by the API only where there are additional items to go to.
The system queries add options to the request that help with keeping count of the number of items displayed in the result.
Method |
Description |
---|---|
$orderby |
The $orderby System query option specifies the order in which items are returned from the service. |
$top |
The $top System query option specifies a non-negative integer n that limits the number of items returned from a collection. |
$skip |
The $skip system query option specifies a non-negative integer n that excludes the first n items of the queried collection from the result |
Pagination default
This request fetches the Items in ascending order, using the $orderby method to sort the items by Item Tag.
-
Duplicate the request 03.04 Vessels + order by Item Tag Asc + selected properties.
-
Add the $count=true method to the request.
https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
Vessels/Com.Ingr.SPID.V2.WEBAPISITE001.PLANT001.Vessel/?$count=true&$orderby= ItemTag&
$select=Id,ItemTag,EquipmentSubclass,EquipmentType,aabbcc_codeThe bottom of the response displays a link to the next items, skipping the first 25 items:
-
Copy the link and paste it in the GET address bar to retrieve the next set of 25 items.
Pagination top items
This request uses '$top' to include only the top number of items in the result. In this case, the request will display only the top three items in the payload (vessels ordered by Item Tag).
-
Select the request 05.01 Pagination top items and click Send.
-
At the end of the previous request, add &$top=3 and click Send.
https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
Vessels/Com.Ingr.SPID.V2.WEBAPISITE001.PLANT001.Vessel/?$count=true&$orderby= ItemTag&
$select=Id,ItemTag,EquipmentSubclass,EquipmentType,aabbcc_code&$top=3
Pagination skip items
This request uses '$skip' to exclude the first n items in the result. In this case, the request will skip the first two items and display the next three items in the payload.
-
Select the request 05.02 Pagination top / skip items and click Send.
https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
Vessels/Com.Ingr.SPID.V2.WEBAPISITE001.PLANT001.Vessel/?$count=true&$orderby= ItemTag&
$select=Id,ItemTag,EquipmentSubclass,EquipmentType,aabbcc_code&$top=3&$skip=2 -
Select the request 05.01 Top items again and click Send.
-
Compare the results of both requests and notice that the first record of the current request was the third record of the previous request.
Pagination top items related to a specific item
This request expands the top three nozzles of a vessel with Id=95A884DDC4714DF0FF30A6ABA5F869F2. You will need to choose a vessel Id appropriate for your data set.
-
Select the request 05.03 Top 3 nozzles for specific vessel and click Send.
https://apiservername.domain.com/WebApi/SPID/V2/Sites('WEBAPISITE001')/Plants('PLANT001')/
Vessels('95A884DDC4714DF0FF30A6ABA5F869F2')/Nozzles/Com.Ingr.SPID.V2.WEBAPISITE001.PLANT001.
Nozzle/?$count=true&$orderby=ItemTag&$select=Id,NozzleType,aabbcc_code,SP_EquipmentID,
SP_PipeRunID&$top=3