Description
I’m trying to query LightDB Stream data via the API and I’m trying to figure out how get all the data within a certain date range using pagination.
Here’s the query I’m using:
curl -X 'POST' \
'https://api.golioth.io/v1/projects/water-level-sensor-b159cd/devices/6849be5632c3e874e7ec9c5a/stream' \
-H 'accept: application/json' \
-H 'x-api-key: <redacted>' \
-H 'Content-Type: application/json' \
-d '{
"start": "2025-07-15T22:39:22.212Z",
"end": "2025-07-17T22:39:22.212Z",
"query": {
"fields": [
{
"path": "time"
},
{
"path": "deviceId"
},
{
"path": "sensor"
}
]
},
"page": 0,
"perPage": 1
}'
This is the response I’m getting:
{
"list": [
{
"deviceId": "6849be5632c3e874e7ec9c5a",
"sensor": {
"accel": {
"x": 0.083334,
"y": 0.151962,
"z": -9.571155
},
"tilt": {
"pitch": -0.9095788157055332,
"roll": -0.4987866350428875
},
"water_level": {
"float_height": -0.5714812202120836,
"float_length": 36,
"float_offset": 0
}
},
"time": "2025-07-17T06:48:58.919656+00:00"
}
],
"page": 0,
"perPage": 1,
"total": 0
}
Should the total
field report the total number of stream records within the date/time range I provided in the original query?
I guess I’m not totally clear on exactly how I should be using the pagination to request all the records within this date/time range. I would assume that I should be calculating the number of pages to request (and therefore the number of page requests to make via the API) based on the total
number of records reported.
What’s the correct way to get all the records for a time/date range if the total number of records exceeds the max 100 records per request?
Environment
API v1