How To GET datapoints of particular Asset's particular Attribute

Hi,

Please help me to know, how can I get recent latest data (attribute value) of particular asset using HTTP API, and how can I see these data into postman response. Thanks in advance.

If you only need the most recent value, requesting the asset automatically includes
all attributes and their current values: GET /api/{realm}/asset/{id}.

You can also use POST /api‚Äč/asset‚Äč/query, which is more common.
This has a lot of configurable options to, for example, only fetch certain attributes from certain assets.

To get for example all values of the last week, you should use the datapoint query endpoint:
POST /api/{realm}/asset‚Äč/datapoint‚Äč/{assetId}‚Äč/attribute‚Äč/{attributeName}
This one is not well documented on swagger, so please ask if you need more details.

.
You can check the swagger documentation on /swagger/ on your local installation,
or check the one from our demo environment: OpenRemote Manager HTTP API Swagger UI

Dear Martin,

Thank you for you prompt reply: as you said to get current values: GET /api/{realm}/{id}

I use the same: got the response - all information is right but no attribute or it’s value shown. See the below picture

And if I am using POST method: it is giving media unsupported error as give below

Just tested the API endpoint myself on my local machine; I do get all attributes and its values.
Are you sure that the asset has attributes configured?
Does the user have the correct permission to get the attribute data?

And no you shouldn’t use POST, which is not used for that endpoint at all.
(as described in the API / swagger documentation I mentioned)

Hi Martin, Thanks for the reply … it seems attributes configured and getting data from MQTT subscribe, service user have read and write both permission. As you can see in below picture but still not getting attributes means still I am missing any thing, can you please tell me detail step to get appropriate response from API.

I guess, in attributes configuration list, we need to do some think… can you please let me know what to configure else?

It seems you have configured the ‚Äėrestricted write‚Äô and ‚Äėrestricted read‚Äô for that service user.
That explains what is going on :wink:

Restricted mode is meant to limit a user to only access a few assets and attributes.
By default, a restricted user does not have access to any attribute.
You need to add the Access restricted read and/or Access restricted write configuration item to the attributes you want them to access.

Hi Martin,
First of all I appreciate your support, now I am able to get current data from this API.
In case if I want to get historical data of an attribute for certain time range, how can I get this?

You should use the datapoint query endpoint for that:
POST /api/{realm}/asset‚Äč/datapoint‚Äč/{assetId}‚Äč/attribute‚Äč/{attributeName}

Specifications like time range, and lots of other configuration options,
can be included in the body of the request like this:

For example:
Using LTTB downsampling algorithm: (default)

{"type":"lttb","fromTimestamp":1688547798146,"toTimestamp":1688634198146,"amountOfPoints":50}

or
Based on interval:

{"type":"interval","fromTimestamp":1688547798146,"toTimestamp":1688634198146,"interval":"1 HOUR","gapFill":false,"formula":"AVG"}

You can change the interval, gapFill and formula (AVG/MIN/MAX) respectively ^

1 Like