First things first - the data.lastValueQuery
endpoint will only return a maximum of 1,000 devices in a single call, whether you pass device IDs or device tags, and that endpoint does not have any pagination features built into it. So if you need 6,000 devices in a single response, that will not work for your use case. Instead, it would require multiple, carefully constructed API calls (as outlined below).
Instead of passing an array of device IDs, pass an array of deviceTags instead. This would require every device you want to retrieve data for to have a common key (but not necessarily a common value). For example …
{
"deviceTags": [{"key": "myKey"}]
}
would return an entry for each device that had a tag with a key of “myKey” regardless of the tag’s value.
In your case, you would need some sort of tag value grouping mechanism to break the devices up in chunks of 1,000 or less, so you would want to tag, say, 800 devices with “myKey=1”, and the next 800 with “myKey=2”, and so on, constructing your tag query as …
{
"deviceTags": [{"key": "myKey", "value": "1"}]
}
If your use case allows it, you could make a single call to the data.export
endpoint that would send all device data and a selection of attributes to either a callback URL or an email address, but it would be on you to wait for that result, download and parse the CSV, and take whatever action you need that data for in your application.
I did make a feature request to allow for returning composite state through the devices.get endpoint (similar to how the Device: Get Node works) and will let you know if it is selected for development and is completed. Bear in mind that would be a paginated endpoint, so you still wouldn’t get 6,000+ devices in a single API call.