Skip to content

Digital Twin API Documentation

To add digital twin data on xrproj you’re going to need to develop a REST api that you serve the data for the software. 

Api Endpoints

The api must have one single endpoint that receives a tags argument and returns an array of items

https://localhost:5000/?tags=a&tags=b&tags=c

Params: 

  • tags: An array of string tags

Example result:

{
    "items": [
        {
            "tag": "a",
            "value": 1,
            "timestamp": "2022-01-15T00:04:00"
        },
        {
            "tag": "b",
            "value": 2,
            "timestamp": "2022-01-15T00:04:00"
        },
        {
            "tag": "c",
            "value": 3,
            "timestamp": "2022-01-15T00:04:00"
        }
    ]
}

The result is an array of items and each item can contain the following properties:

  • tag: The item tag
  • timestamp: When this item value has been updated
  • value: The value of the item
  • alarm: You might indicate that something is wrong the the current value 

Possible value types

  • Text: A plain text
  • Number: A number (both integer and floating point)
  • Boolean: Return true/false or 0/1
  • Date: An ISO date/time string
  • Image: Image url or base64 string
  • Table: An array of tables

Table data structure

The table will have 2 main properties:

  • name: The display name of the table
  • items: An array of table items

Example table data:

{
    "name": "Vistorias",
    "items": [
        {
            "name": "Data Vistoria",
            "value": "14/04/22"
        },
        {
            "name": "Foto 01",
            "value": "http://www.link.to.my.image",
            "isImage": true
        }
    ]
}

Alarms

Your api might inform XRProj that something is wrong with your data.

The return an alarm you have to use the alarm property in the digital twin item with the following structure:

  • startTime [Optional]: When did the problem start?
  • status: Warning/Error/Critical
  • description [Optional]: Describe the problem  

Ex: data with alarm:

{
    "items": [
        {
            "tag": "water_temperature",
            "value": 200,
            "alarm": {
                "startTime": "2022-01-12T01:54:17",
                "status": "Critical",
                "description": "The water temperature must be between 50° and 100°"
            },
            "timestamp": "2022-01-15T00:04:00"
        }
    ]
}