Contact Us
Download N3uron
Back to videos

REST API Server / Retrieving Historical Data in REST API Server

Retrieving Historical Data in REST API Server

Description

In this video of our N3uron Academy, we’re going to explore how to retrieve historical data using N3uron’s REST API Server Module. Let’s get started!

  • [05:19] Retrieving Historical Data in REST API Server

Transcription

[00:00] Hello everyone! In today’s video, we’re going to explore how to retrieve historical data using N3uron’s REST API Server Module. For demonstration purposes, we’ll use Postman as our API testing tool, following N3uron’s REST API Server documentation to structure our requests correctly. Before we continue, we need to ensure that a Historian module instance is available. To create one, navigate to System > Config > Modules, click on the burger menu, and select New Module. Then, assign a meaningful name such as Historian, and set the module type to Historian. In our case, we have already created a Historian module instance and configured it to connect to an external Mongo database, but you can also choose to use the embedded Mongo database.

[01:00] Now, let’s move to Postman. Within our collection, we have already created a Tag History request, so let’s take a look at this API request alongside the API documentation. For authorization, we’ll use Basic Authorization by providing the admin user credentials. Note that in this case, we use global variables for the username and password, enclosed in double curly braces; however, you can also input the credentials directly. For more details on using global variables in Postman, please refer to the Postman documentation. First, we’ll retrieve historical data from a single tag. The endpoint is tag, and the command is history. We need to specify a start and end date for the request. We’ll also include the mode option set to aggregated, the method set to delta, and an interval of 1 hour, which must be provided in milliseconds. This means we will retrieve historical data showing the difference between the first and last values for each hour.

[02:00] Since Active_Energy is measured in kilowatt-hours, the response will provide the energy produced per hour for the selected time range. Let’s send the request and compare the response by visualizing the same historical data request in WebUI. As we can see, the data matches, confirming that our request is correct. Next, let’s retrieve historical data for multiple tags using the History Many command. For this request, we’ll use the same endpoint and provide a comma-separated list of tag paths for which we want historical data. The paths format can also be provided as a JSON array.

[03:01] We’ll send a historical request for Active Energy, Capacity Factor, and Performance Ratio of our photovoltaic plant. The remaining parameters are the same as in our previous request. Now, let’s send the request. As we can see, the response contains historical data for each tag we specified in the paths parameter. Next, we’ll send a request to retrieve historical data using the Filtered History command. The endpoint remains the same, with the command historyFilter. With this request, we can retrieve historical data using regular expressions, allowing us to filter specific tags dynamically. The regular expression can be as complex as needed. For this example, we’ll set the root folder as the path and enable the recurrent option. We’ll also set the filter option to retrieve only tags that include the word “Current” in their full path.

[04:02] The remaining parameters will be the same as in our previous requests, but this time, the aggregation method will be set to average, meaning we’ll get the average values for the specified interval, which is again 1 hour, provided in milliseconds. Now, let’s send the request. In the response, we can see that some tags return “Error: Historization disabled for the target tag.” This is expected behavior, as those tags do not have historization enabled, and the regular expression used was too broad. We can verify this in the History configuration for the tags in question. 

[05:04] That’s it for this video! In the next videos, we’ll cover how to create and export backups of the node using the REST API. Thanks for watching, and see you in the next video!

Privacy Settings
We use cookies to enhance your experience while using our website. If you are using our Services via a browser you can restrict, block or remove cookies through your web browser settings. We also use content and scripts from third parties that may use tracking technologies. You can selectively provide your consent below to allow such third party embeds. For complete information about the cookies we use, data we collect and how we process them, please check our Privacy Policy
Youtube
Consent to display content from - Youtube
Vimeo
Consent to display content from - Vimeo
Google Maps
Consent to display content from - Google
Spotify
Consent to display content from - Spotify
Sound Cloud
Consent to display content from - Sound
Contact Us
Download N3uron