How to get all the values in measurement series endpoint

*Product/components used, and version/fix level are you on: *

Cumulocity Free Trial

Hi, I am trying to query some measurement types in measurement series endpoint. Is there any way to get all the series in 1 go only? Right now we need to mention series = measurement.type but is there way to get all the measurements with 1 param only?

Best Regards,
Samanyu

Hello @Sam123 ,

please check out the measurement series API:
https://cumulocity.com/api/10.15.0/#operation/getMeasurementSeriesResource

There you can query all measurement-types for a specific device, optionally also by a specific measurement-series.

Could you elaborate how you currently query the measurements in detail?

Regards
Kai

Hi Kai,

Let’s say I have a measurement called ABC, with 1000 types. Now for accessing it through series I need to type Series = ABC.X & Series = ABC.Y in the URL to access X and Y measurement type. Now, I need to get the data for all 1000 types from the series Api, so it won’t be a feasible solution to provide all the 1000 types in the URL. So is there any way to call those 1000 types through 1 or 2 params rather than calling using 1000 params in the URL.

Best Regards,
Samanyu

Can you provide a JSON example of such a measurement?
Depending on the response format you could also use the measurement API (not to be confused with the measurement series API).
By this you can also just query for your measurement type (ABC) and get all related series (X, Y).

Getting “all” measurements is in both cases challenging, it depends on for which time-range you want to get all measurements.

Hi Kai,

Let’s say for example, I have a measurement type : “ABC”. which has some specific types under it like X and Y.

{
    "source": {
        "id": "1234"
    },
    "time": "2023-05-09T09:30:30.502Z",
    "type": "ABC",
    "ABC": {
        "X": {
            "unit": "",
            "value": 2
        },
        "Y": {
            "unit": "",
            "value": 2
        }
    }
}

Now lets say similar to X and Y types I have 1000 types like that. From measurement API, i can fetch all the data but I want to fetch it from series API because it provides me aggregated values for the types i mention in the params and it also gives me null if the value is not present in that particular timestamp.

Example of the series API will be:

{
    "values": {
        "2023-05-09T09:30:30.500Z": [
            {
                "min": 2,
                "max": 2
            },
            {
                "min": 2,
                "max": 2
            },
             "2023-05-10T16:20:20.200Z": [
           null,
            {
                "min": 2,
                "max": 2
            }
},
"series": [
        {
            "unit": "",
            "name": "X",
            "type": "ABC"
        },
        {
            "unit": "",
            "name": "Y",
            "type": "ABC"
        }
],
"truncated" : false
}

Now in this example you can see i am getting null for a certain timestamp. In my use case I want the data in this format. Now the url for this would form like:
/measurement/measurement/series?dateFrom=“” & dateTo=“”, series =ABC.X & series =ABC.Y

So for this when i am fetching only 2 values, it is easy for me to pass 2 values in params but in my use case i have 1000 and i cannot pass 1000 values in the url itself. So my question is, is there any way to get all the measurements in series API just by specifying the type like series = ABC.* ( this will get me all the type values which comes under ABC)

Hope this will make you understand my query.

Best Regards,
Samanyu


Documentation for this is specific - use a list of comma separated series.

Sure 1000 is too many, but presently we can offer no other way than the above.

Maybe query a couple of hundred at a time and merge the results somehow?

As Robert already stated, this is the only feasible way for the series API.

The only alternative is to use the measurement API and use the valueFragmentType or type property to only get “ABC” measurements.
The advantage here is that the measurement API also supports paging, but no aggregation.

Hi Robert and Kai,

Thank you for your insights. Just wanted to know if there is a way or not.

Best Regards,
Samanyu

No problem! Keep asking - it’s what makes this community such a valuable resource.

2 Likes

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.