REST API Server / Retrieving Historical Data in REST API Server
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!
[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!
N3uron software is an Industrial Edge Platform for IIoT and DataOps that streamlines the flow of data between industrial systems and business applications, either on-premise or in the cloud. N3uron provides an out-of-the-box solution for data standardization, normalization and contextualization, seamless integration with industrial and IT systems, efficient information management, and unparalleled scalability and security. The N3uron platform makes it easier for operations teams to aggregate, manage and analyze industrial data, resulting in enhanced productivity and informed decision-making. Whether you're looking to optimize your operations, reduce downtime or improve product quality, the N3uron platform is the answer.
CONTRIBUTING MEMBER
N3uron is a Contributing Member of the Eclipse Foundation, actively participating in the development of their robust ecosystem. By leveraging EF technologies, we offer innovative products and services that drive our corporate strategy forward. N3uron is Sparkplug Compatible Software.
DLMS® UA MEMBER
N3uron is a member of the DLMS® User Association, the global community that drives standardization in the energy and water industry. Being part of the DLMS UA represents N3uron's commitment to advancing smart metering and energy management solutions.
FOLLOW US
N3uron Connectivity Systems • Paseo de la Castellana, 91, 4º, 1; Madrid, 28046, Spain • +34 911 841 938 • [email protected]
N3uron software is an Industrial Edge Platform for IIoT and DataOps that streamlines the flow of data between industrial systems and business applications, either on-premise or in the cloud. N3uron provides an out-of-the-box solution for data standardization, normalization and contextualization, seamless integration with industrial and IT systems, efficient information management, and unparalleled scalability and security. The N3uron platform makes it easier for operations teams to aggregate, manage and analyze industrial data, resulting in enhanced productivity and informed decision-making. Whether you're looking to optimize your operations, reduce downtime or improve product quality, the N3uron platform is the answer.
CONTRIBUTING MEMBER
N3uron is a Contributing Member of the Eclipse Foundation, actively participating in the development of their robust ecosystem. By leveraging EF technologies, we offer innovative products and services that drive our corporate strategy forward. N3uron is Sparkplug Compatible Software.
CONTRIBUTING MEMBER
N3uron is a Contributing Member of the Eclipse Foundation, actively participating in the development of their robust ecosystem. By leveraging EF technologies, we offer innovative products and services that drive our corporate strategy forward. N3uron is Sparkplug Compatible Software.
FOLLOW US
N3uron Connectivity Systems • Paseo de la Castellana, 91, 4º, 1; Madrid, 28046, Spain • +34 911 841 938 • [email protected]
N3uron software is an Industrial Edge Platform for IIoT and DataOps that streamlines the flow of data between industrial systems and business applications, either on-premise or in the cloud. N3uron provides an out-of-the-box solution for data standardization, normalization and contextualization, seamless integration with industrial and IT systems, efficient information management, and unparalleled scalability and security. The N3uron platform makes it easier for operations teams to aggregate, manage and analyze industrial data, resulting in enhanced productivity and informed decision-making. Whether you're looking to optimize your operations, reduce downtime or improve product quality, the N3uron platform is the answer.
CONTRIBUTING MEMBER
N3uron is a Contributing Member of the Eclipse Foundation, actively participating in the development of their robust ecosystem. By leveraging EF technologies, we offer innovative products and services that drive our corporate strategy forward. N3uron is Sparkplug Compatible Software.
DLMS® UA MEMBER
N3uron is a member of the DLMS® User Association, the global community that drives standardization in the energy and water industry. Being part of the DLMS UA represents N3uron's commitment to advancing smart metering and energy management solutions.
FOLLOW US
N3uron Connectivity Systems • Paseo de la Castellana, 91, 4º, 1; Madrid, 28046, Spain • +34 911 841 938 • [email protected]