All endpoints accept "Content-Type: application/json" for incoming request data.
With the exception of auth/token this data must be formatted as"Content-Type: application/x-www-form-urlencoded" OAUTH 2.0 - RFC 6749 (Page 15 - Client Password flow.)
You are now Logged in.
Explore some common RestAPI usages.
Logging into the api does use a different flow compared to other endpoints. It follows OAUTH 2.0 - RFC 6749, meaning that data must be application/x-www-form-urlencoded
After a successful login using password authentication flow you will recieve a model like the one below
The token is good for 15 minutes with a rolling window. If you ever receive a 401 Unauthorized, simply reauthenticate.
{ "access_token": "string", "token_type": "string", "userId": 0 }
Often you will want to get data for all hardware on a site we will explain breifly how you acheive this.
First we will have to get all the hardware on the site, you can either choose to get the hardware with or without the archive fields, the archive fields are the fields that are saved into the database for later retreival.
If we choose not to get the archive fields we can just use the hardware id's in the response to get the full details about the hardware and registers.
After getting the hardware you will end up with the following object
{ "hardware": [{ "id": 0, "stringId": "string", "functionCode": "string", "flags": [ "None" ], "fieldsArchived": [ "string" ], "name": "string", "lastUpdate": "2019-09-25T23:16:46.214Z", "timeZone": "string", "iconUrl": "string", "alertCount": 0, }] }
Alternativley you can first collect all the hardware id's on the site then get the detailed hardware object.
After getting the hardware you will end up with the following object
{ "hardware": [{ "id": 0, "stringId": "string", "functionCode": "string", "flags": [ "None" ], "name": "string", "lastUpdate": "2019-09-25T23:16:46.214Z", "timeZone": "string", "iconUrl": "string", "alertCount": 0, }] }
After getting all the simple hardware details on the site we will have to get the detailed hardware object, meaning we will have to call the below method once for each hardware on site.
After getting the individual hardware you will end up with the following object
The RegisterData groups describe the archived columns along with all other data associated to the registers. Hardware.registerGroups[].registers[]{ "id": 0, "name": "string", "stringId": "string", "flags": [ "None" ], "gatewayId": "string", "address": "string", "functionCode": "Unknown", "port": 0, "portMode": "string", "serialNumber": "string", "lastUpdate": "2019-09-25T23:21:37.969Z", "timeZone": "string", "config": { ... // truncated for clarity }, "driver": { "name": "string", "settings": { "additionalProp1": "string", "additionalProp2": "string", "additionalProp3": "string" } }, "registerGroups": [ { "name": "string", "registers": [ { "address": "string", "rawValue": "string", "value": "string", "isArchived": true, "name": "string", "dataName": "string" } ] } ] }After obtaining info about the archived fields we can now query the values from the api.
[ { "hardwareId": 0, "siteId": 0, "fieldName": "string", "function": "Avg" } ]
Often you will want to get calculated data for a site, in order to acheive this. We will need to utalize the chart endpoints.
Based on the hardware available different charts are available. Comparing to powertrack web, the custom tab in charts represents the Custom endpoint, whereas, the Built-in tab represents the basic chart endpoint.
When making chart requests a Span or End Time can be used, Span's take presedence over End Time, leave span null or set to custom to use End Time.
Please note that all charting response are compatible with Open Source .NET plotting library OxyPlot
First we need to determine what chart we want. To start we will get all the charts available for the hardware we are intrested in, generally I simply use all the hardware on the site, or the site endpoint.
Response
{ "items": [ { "chartId": 0, "chartName": "string", "chartSpans": [ "string" ], "supportedHardware": [ { "id": 0, "name": "string", "type": "Unknown", "iconUrl": "string" } ] } ] }
Using this information, you can call the chart endpoint.
Please note that all charting response are compatible with OpenSource plotting library OxyPlot
First we need to determine what chart we want. To start we will get all the charts available for the hardware we are intrested in, generally I simply use all the hardware on the site.
{ "measurements": [ { "id": "string", "name": "string", "displayName": "string", "checkboxOptions": [ { "name": "string", "isSelected": true } ], "dropdownOptions": [ { "options": [ "string" ], "selected": "string" } ] } ], "calculations": [ { "id": "string", "name": "string", "displayName": "string", "checkboxOptions": [ { "name": "string", "isSelected": true } ], "dropdownOptions": [ { "options": [ "string" ], "selected": "string" } ] } ], "losses": [ { "id": "string", "name": "string", "displayName": "string", "checkboxOptions": [ { "name": "string", "isSelected": true } ], "dropdownOptions": [ { "options": [ "string" ], "selected": "string" } ] } ], "financials": [ { "id": "string", "name": "string", "displayName": "string", "checkboxOptions": [ { "name": "string", "isSelected": true } ], "dropdownOptions": [ { "options": [ "string" ], "selected": "string" } ] } ] }
After we find the chart we want we can use the below endpoint to get the chart data.
Please note that all charting response are compatible with OpenSource plotting library OxyPlot
Find a sample chart response below.
{ "data": [ { "title": "string", "xAxisKey": "string", "yAxisKey": "string", "isStacked": true, "stackGroup": "string", "seriesType": "Unknown", "smooth": true, "points": [ { "x": "string", "y": "string" } ], "points2": [ { "x": "string", "y": "string" } ], "items": [ { "value": "string", "categoryIndex": 0 } ] } ], "axes": [ { "title": "string", "minimum": "string", "maximum": "string", "key": "string", "isAxisVisible": true, "labels": [ "string" ], "axisType": "LinearAxis", "axisCoordinate": "XCoordinate" } ] }