
WhatsUp Rest API (Archived) — Dragos Stan (Customer) asked a question.
Paging setup for WUG RestAPI
Hey folks,
I've been trying to get all the devices in my organisation using the API WhatsUp provides but I hit a limitation or a bug maybe. When I try to increase the size of the page (which is by default set to 200) using the limit query parameters, I can't seem to go above the 200 entries per page. Lower than 200 works fine but higher just returns 200 results.
According to the API docs that param is a 32 bit integer so it should go way higher than 200 :)
Any ideas on this one? Here's what I'm querying:
http://my-wug.com:9644/api/v1/device-groups/0/devices?limit=250
Thanks!
Hi Dragos,
Its not a bug,
I still wasnt able to test most of the calls but for the knowledge that I have of APIs, you have to implement a series of calls until you reach the last page.. you cant call all of them at once even if the limit variable is a 32bit integer, the api engine cant handle all at once (based on your tests looks like its 200).
So you have to do a loop of calls until the last page, the nextpage id is in each response.
RESPONSE:
{
"data": {
"devices": [
{...array_data...}
]
},
"paging": {
"size": 1000,
"pageId": "1",
"nextPageId": "2"
}
}
in this example you first call lets say with a limit of 100, the result is saing: (size:1000="there are 1000 devices in total in the group" but you will get the first "100", pageid=is the page you are and the next pageid. ). so in your calls should be:
/api/v1/device-groups/{groupId}/devices?limit=100
/api/v1/device-groups/{groupId}/devices?limit=100&pageId=2
/api/v1/device-groups/{groupId}/devices?limit=100&pageId=3
... and so on until lastpage.
Take a look at a diagram I made (attached).
PD. Im assuming that the variable "size" in the response is the total size of the call. ie. size=1000 but getting on blocks of 100.
Ref:
https://docs.ipswitch.com/NM/WhatsUpGold2021/02_Guides/rest_api/#tag/DeviceGroup
Best Regards,
Randol
Thanks Randol, that is the design of the apis. Paging allows the caller of the api to limit the amount of data it has to deal with and optimize the amount of data on the wire if they want. In turn, the back end has a maximum number of entries per page so no one caller can overwhelm the system, causing large transactions, memory or cpu use.