Beacon Metric APIs
Introduction
This document describes how to use the Beacon Metrics API to retrieve historical metric data from Bluzone. Note: data older than 6 months is not available through any of these APIs.
Metrics by Beacon
Method | GET |
---|---|
URL | https://bluzone.io/portal/papis/v1/history/metric/{projectId} |
Response Content-Type | application/json OR text/csv (depending on the format parameter) |
Header | bzid |
Description | Get history of a single metric. If a beacon is not specified, the API will return the data for all the beacons in the project |
Parameters
Type | Name | Required | Description | Schema | Default |
---|---|---|---|---|---|
Path | projectId | YES | The project Id, e.g. | int64 | |
Query | beaconId | NO | The id of the beacon, e.g. Multiple beaconIds should be separated by commas, e.g. | string <array> | **all beacons in project |
Query | interval | YES | The interval for the metric, i.e. the granularity of the data, e.g. | enum
| |
Query | metric | YES | The type of metric requested, e.g. | enum
| |
Query | startDate | YES | The start date of the data requested. Must be in ISO 8601 format compliant, e.g. | string | |
Query | endDate | YES | The end date of the data requested. Must be in ISO 8601 format compliant, e.g. | string | |
Query | format | YES | The desired format of the data, e.g. | enum
| |
Query | download | NO | Whether to include a Content-Disposition header, e.g. | boolean | true |
Request
curl -X GET \ https://bluzone.io/portal/papis/v1/history/metric/$PROJECT_ID?beaconId=$BEACON_ID&metric=TEMP&interval=1d&endDate=2019-02-20T20:30:40.140Z&startDate=2019-02-17T20:30:40.140Z&includeZeros=true&format=json&merge=true&_=1550694639186 \ -H 'bzid: $PROJECT_API_KEY'
Response
[ { "metric": "temp", "id": {beaconId}, "keyAsString": "2019-02-18T00:00:00Z", "key": 1550448000, "count": 3774, "sum": 87441.25, "avg": 23.169382617912028, "rms": 0, "rmsPeak": 0, "min": 21.25, "peak": 25, "peakToPeak": 3.75 }, { "metric": "temp", "id": {beaconId}, "keyAsString": "2019-02-19T00:00:00Z", "key": 1550534400, "count": 3236, "sum": 66882, "avg": 20.668108776266997, "rms": 0, "rmsPeak": 0, "min": 19.75, "peak": 21.5, "peakToPeak": 1.75 }, { "metric": "temp", "id": {beaconId}, "keyAsString": "2019-02-20T00:00:00Z", "key": 1550620800, "count": 3336, "sum": 68010.75, "avg": 20.3869154676259, "rms": 0, "rmsPeak": 0, "min": 19.75, "peak": 21.5, "peakToPeak": 1.75 } ]
Download Storage
Method | GET |
---|---|
URL | https://bluzone.io/portal/papis/v1/history/storage/download/{projectId} |
Response Content-Type | application/json |
Header | bzid |
Description | Storage data in json format |
Parameters
Type | Name | Required | Description | Schema | Default |
---|---|---|---|---|---|
Path | projectId | YES | The project Id, e.g. | int64 | |
Query | beaconId | NO | The id of the beacon, e.g. Multiple beaconIds should be separated by commas, e.g. | string <array> | **all beacons in project |
Query | startDate | YES | The start date of the data requested. Must be in ISO 8601 format compliant, e.g. | string | |
Query | endDate | YES | The end date of the data requested. Must be in ISO 8601 format compliant, e.g. | string | |
Query | download | NO | Whether to include a Content-Disposition header, e.g. | boolean | false |
Query | dataType | YES | The advertisement data being request, e.g. | enum <array>
|
Request
curl -X GET \ https://bluzone.io/portal/papis/v1/history/storage/download/$PROJECT_ID?startDate=2019-02-17T20:30:40.140Z&endDate=2019-02-20T20:30:40.140Z&dataType=sBv2 \ -H 'bzid: $PROJECT_API_KEY'
Reponse
{ "advData":{ "id": {beaconId}, "time":1506014675, "eventCounter":[ 16, 6, 14 ], "xAccel":0.01953125, "yAccel":0.0078125, "zAccel":0.02734375, "adapter":{ "type":3, "gid":"0E61B3B3-BD15-4F42-BD0D-04AEA34D5B13" } }, "environment_name":"bzprod", "projectId":3089, "serverTimestamp":1506014675000, "type":"sSns" }
Aggregate Metric by Beacon
Method | GET |
---|---|
URL | https://bluzone.io/portal/papis/v1/history/metric/aggregate/{projectId} |
Response Content-Type | application/json OR text/csv (depending on the format parameter) |
Header | bzid |
Description | Get all aggregate metric history for a beacon(s) |
Parameters
Type | Name | Required | Description | Schema | Default |
---|---|---|---|---|---|
Path | projectId | YES | The project Id, e.g. | int64 | |
Query | beaconId | NO | The id of the beacon, e.g. Multiple beaconIds should beseparated by commas, e.g. | string | |
Query | interval | YES | The interval for the metric, i.e. the granularity of the data, e.g. | enum
| |
Query | startDate | YES | The start date of the data requested. Must be in ISO 8601 format compliant, e.g. | string | |
Query | endDate | YES | The end date of the data requested. Must be in ISO 8601 format compliant, e.g. | string | |
Query | format | YES | The desired format of the data, e.g. | enum
| |
Query | download | NO | Whether to include a Content-Disposition header, e.g. | boolean | false |
Request
curl -X GET \ https://bluzone.io/portal/papis/v1/history/metric/aggregate/$PROJECT_ID?beaconId=$BEACON_ID&interval=1d&startDate=2019-02-17T20:30:40.140Z&endDate=2019-02-20T20:30:40.140Z&format=json \ -H 'bzid: $PROJECT_API_KEY'
Response
[ { "id": {beaconId}, "keyAsString":"2017-09-21T00:00:00Z", "key":1505952000, "tempCount":13153.0, "tempAvg":21.247001634608075, "tempSum":279461.8125, "rssiCount":13150.0, "rssiAvg":-48.440532319391636, "rssiSum":-636993.0, "lumsCount":1.0, "lumsAvg":138.0, "lumsSum":138.0, "magStateCount":17.0, "magStateAvg":0.47058823529411764, "batteryCount":13150.0, "batteryAvg":3609.9946768060836, "batterySum":4.747143E7, "tempPeak":27.25, "rssiPeak":0.0, "lumsPeak":138.0, "batteryPeak":3660.0, "magstateSum":8.0, "magStatePeak":1.0, "zaccelAvg":-0.44839638157894735, "zaccelRms":0.7144529620100675, "zaccelSum":-34.078125, "zaccelSqSum":38.793670654296875, "zaccelPeak":0.96484375, "zaccelMin":-1.21484375, "zaccelPeakToPeak":2.1796875, "xhsCount":0.0, "xhsRmsAvg":0.0, "xhsRmsSum":0.0, "xhsPeak":0.0, "xhsPeakToPeak":0.0, "yhsCount":0.0, "yhsRmsAvg":0.0, "yhsRmsSum":0.0, "yhsPeak":0.0, "yhsPeakToPeak":0.0, "zhsCount":0.0, "zhsRmsAvg":0.0, "zhsRmsSum":0.0, "zhsPeak":0.0, "zhsPeakToPeak":0.0, "xmagCount":17.0, "xmagAvg":359.88235294117646, "xmagSum":6118.0, "xaccelCount":76.0, "xaccelAvg":-0.006064967105263158, "xaccelRms":0.47803013939545264, "xaccelSum":-0.4609375, "xaccelSqSum":17.366973876953125, "xaccelPeak":0.84375, "xaccelMin":-1.0234375, "xaccelPeakToPeak":1.8671875, "yaccelCount":76.0, "yaccelAvg":-0.1953638980263158, "yaccelRms":0.42104968270724796, "yaccelSum":-14.84765625, "yaccelSqSum":13.473495483398438, "yaccelPeak":0.375, "yaccelMin":-0.9921875, "yaccelPeakToPeak":1.3671875, "zaccelCount":76.0, "xmagPeak":1720.0, "ymagCount":17.0, "ymagAvg":-834.4705882352941, "ymagSum":-14186.0, "ymagPeak":247.0, "zmagCount":17.0, "zmagAvg":1166.2941176470588, "zmagSum":19827.0, "zmagPeak":2497.0 } ]
Raw Metric by Beacon
Method | GET |
---|---|
URL | https://bluzone.io/portal/papis/v1/history/metric/raw/{projectId} |
Response Content-Type | application/json OR text/csv (depending on the format parameter) |
Header | bzid |
Description | Get raw metric history data |
Parameters
Type | Name | Required | Description | Schema | Default |
---|---|---|---|---|---|
Path | projectId | YES | The project Id, e.g. | int64 | |
Query | beaconId | NO | The id of the beacon, e.g. Multiple beaconIds should be separated by commas, e.g. | string | |
Query | dataType | YES | The advertisement data being request, e.g. | enum
| |
Query | storageType | YES | Describe how you would like the fetch the data. ALL will query both cache and long term storage for result. CACHE: only hits cache. STORAGE: only hits long term storage. For Example, storageType=all | enum
| |
Query | filter | NO | Filter the type of raw metric. Each filter should be separated by a comma, e.g. | enum
| |
Query | deviceJobId | NO | Filter by deviceJobId | int64 | |
Query | sessionId | NO | Filter by sessionId | string | |
Query | startDate | YES | The start date of the data requested. Must be in ISO 8601 format compliant, e.g. startDate=2017-09-11T13:39:57.420Z . | string | |
Query | endDate | YES | The end date of the data requested. Must be in ISO 8601 format compliant, e.g. | string | |
Query | format | YES | The desired format of the data, e.g. | enum
| |
Query | header | NO | Whether to include headers in the CSV (only applicable when format=csv) | boolean | true |
Query | separator | NO | The separator for the CSV response. By default, commas are used, if the separator is "eu" then semi-colons are used. Any separator can be used as long as it's only a single character, e.g. separator= _ (only applicable when format=csv) | string | default |
Request
curl -X GET \ https://bluzone.io/portal/papis/v1/history/metric/raw/$PROJECT_ID?beaconId=$BEACON_ID&dataType=sSnsSummary&storageType=all&startDate=2019-02-17T20:30:40.140Z&endDate=2019-02-20T20:30:40.140Z&format=json&storageType=all&filters=adv \ -H 'bzid: $PROJECT_API_KEY'
Response
{ "beaconId":[ {beaconId} ], "blufiId":null, "conditionSummary":{ "yPeakToPeak":0.0, "adv":0.0, "highRes":0.0, "sourceTime":0.0, "xPeak":0.0, "xPeakToPeak":0.0, "xRms":0.0, "yPeak":0.0, "yRms":0.0, "zPeak":0.0, "zPeakToPeak":0.0, "zRms":0.0 }, "dateKey":123, "datesStringKey":"2017-09-20T13:39:57.420Z", "projectId": {projectId} }
RCM Aggregate by Beacon
Method | GET |
---|---|
URL | https://bluzone.io/portal/papis/v1/history/addata/{projectId}/magstate |
Response Content-Type | application/json OR text/csv (depending on the format parameter) |
Header | bzid |
Description | Get remote condition monitoring data mag state aggregation |
Parameters
Type | Name | Required | Description | Schema | Default |
---|---|---|---|---|---|
Path | projectId | YES | The project Id, e.g. | int64 | |
Query | beaconId | NO | The id of the beacon, e.g. Multiple beaconIds should be separated by commas, e.g. | string | |
Query | startDate | YES | The start date of the data requested. Must be in ISO 8601 format compliant, e.g. startDate=2017-09-11T13:39:57.420Z . | string | |
Query | endDate | YES | The end date of the data requested. Must be in ISO 8601 format compliant, e.g. | string | |
Query | format | YES | The desired format of the data, e.g. | enum
| |
Query | baseTemp | NO | float | ||
Query | details | NO | boolean | false | |
Query | download | NO | Whether to include a Content-Disposition header, e.g.Content-Disposition: attachment; filename="mag-state-aggregation_project-3089_09-20-2017_13-39-57-09-24-2017_13-39-57.json" | boolean | true |
Query | raw | NO | boolean | false | |
Query | showClosed | NO | boolean | false | |
Query | header | NO | Whether to include headers in the CSV (only applicable when format=csv) | boolean | true |
Query | separator | NO | The separator for the CSV response. By default, commas are used, if the separator is "eu" then semi-colons are used. Any separator can be used as long as it's only a single character, e.g. separator= _ (only applicable when format=csv) | enum
| default |
Request
curl -X GET \ https://bluzone.io/portal/papis/v1/history/addata/$PROJECT_ID/magstate?beaconId=$BEACON_ID&startDate=2019-02-17T20:30:40.140Z&endDate=2019-02-20T20:30:40.140Z&format=json&showClosed=true&details=true \ -H 'bzid: $PROJECT_API_KEY'
Response
[ { "beaconId":"1015467935288056038", "date":"2017-09-21T17:24:37Z", "duration":"1m 40s", "xMag":260.0, "yMag":-964.0, "zMag":1203.0, "temp":null, "opened":true }, { "beaconId":"1015467935288056038", "date":"2017-09-21T17:26:17Z", "duration":"1s", "xMag":326.0, "yMag":-770.0, "zMag":1345.0, "temp":null, "opened":false }, { "beaconId":"1015467935288056038", "date":"2017-09-21T17:26:18Z", "duration":"14s", "xMag":404.0, "yMag":-1056.0, "zMag":1243.0, "temp":null, "opened":true }, { "beaconId":"1015467935288056038", "date":"2017-09-21T17:26:32Z", "duration":"3s", "xMag":270.0, "yMag":-597.0, "zMag":259.0, "temp":null, "opened":false } ]
Raw Scan Data by Beacon
Method | GET |
---|---|
URL | https://bluzone.io/portal/papis/v1/history/addata/{projectId}/rawData |
Response Content-Type | text/csv |
Header | bzid |
Description | Get remote condition monitoring data mag state aggregation |
Parameters
Type | Name | Required | Description | Schema | Default |
---|---|---|---|---|---|
Path | projectId | YES | The project Id, e.g. | int64 | |
Query | beaconId | NO | The id of the beacon, e.g. Multiple beaconIds should be separated by commas, e.g. | string | |
Query | startDate | YES | The start date of the data requested. Must be in ISO 8601 format compliant, e.g. startDate=2017-09-11T13:39:57.420Z . | string | |
Query | endDate | YES | The end date of the data requested. Must be in ISO 8601 format compliant, e.g. | string | |
Query | format | YES | The desired format of the data, e.g. | enum
| |
Query | download | NO | Whether to include a Content-Disposition header, e.g.Content-Disposition: attachment; filename="mag-state-aggregation_project-3089_09-20-2017_13-39-57-09-24-2017_13-39-57.json" | boolean | true |
Query | rcmOnly | NO | Whether you only want remote condition monitoring data, e.g. rcmOnly=true | ||
Query | header | NO | Whether to include headers in the CSV (only applicable when format=csv) | boolean | true |
Query | separator | NO | The separator for the CSV response. By default, commas are used, if the separator is "eu" then semi-colons are used. Any separator can be used as long as it's only a single character, e.g. separator= _ (only applicable when format=csv) | enum
| default |
Query | dataType | YES | The advertisement data being request, e.g. dataType=sBv2 | enum
|
Request
curl -X GET \ https://bluzone.io/portal/papis/v1/history/addata/$PROJECT_ID/rawData?format=csv&beaconId=$BEACON_ID&startDate=2019-02-17T20:30:40.140Z&endDate=2019-02-20T20:30:40.140Z&dataType=sBv2 \ -H 'bzid: $PROJECT_API_KEY'
Response
blufiId,projectId,type,serverTimestamp,rssi,rssiCh,bpm,uuid,id,time,major,minor,measuredPower,sdc,bat,batt,temp,txPower,txChn,lums,eventCounter,xAccel,yAccel,zAccel,motion,raw,xMag,yMag,zMag,flags,bdId,gid,adFlags,adType,ad16bit,ad16bitMore,ad32bit,ad32bitMore,ad128bit,ad128bitMore,adNameShort,adNameLong,adPower,@timestamp,addr2,frameCount,instanceIdentifier,length,namespaceIdentifier,revision,ssid,started,staticHash,timeNano,uptime,url,xPeak,xPeakToPeak,xRms,yPeak,yPeakToPeak,yRms,zPeak,zPeakToPeak,zRms ,{projectId},sBv2,1506014675000,0,0,0,,1015467935288056038,1506014675,0,0,0,0,0,0,0.0,0,0,138,,0.0,0.0,0.0,,,0,0,0,0,,0E61B3B3-BD15-4F42-BD0D-04AEA34D5B13,,,,,,,,,,,,,,0,,,,0,,0,,,0,,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0