Data monitor

Send Data Monitor Records

POST https://api.upswift.io/v1/send_app_monitor

Using this call, you can send any parameter and value from the edge device to Upswift servers.

Request Body

{"message": "Success"}

Example

import json
import requests


#Upswift tokens
user_token = "<user token>"
device_token = "<device token>"

json_content = {'user_token': user_token,
                'device_token': device_token,
                'app_parameters': [{'app_parameter_name': "Temperature", 'app_parameter_value': "23c"},
                                   {'app_parameter_name': "Counter", 'app_parameter_value': "123"}]}

call_request = requests.post("https://api.upswift.io/v1/send_app_monitor", json=json_content)
call_response = json.loads(call_request.text)

if call_request.status_code != 200:
    if call_request.status_code == 429:
        error = "API limit reached"
    else:
        error = call_response["error_message"]
    print(error)
else:
    response_message = call_response["message"]

Get Data Monitor Records

GET https://api.upswift.io/v1/app_monitor_details

Using this call, you will get the last 100 Data Monitor records that were received from your devices.

Request Body

{"message": [{"device_id": 123456,
             "app_parameter_name": "Temperature",
             "app_parameter_value": "23",
             "created_time": "2020-02-08 16:12:11"}]}

If you set device_token, you will receive the records for that device regardless if you also set the project_name. If only project_name is set, you will receive records from all devices of that project. If both of them are not set, you will receive records from all devices from all projects.

Example

import json
import requests
json_content = {'device_token': 'XXXXXXXXXXXXXXXXX',
                'user_token': 'YYYYYYYYYYYYYYY',
                'project_name': "TestProject"}

call_request = requests.get("https://api.upswift.io/v1/app_monitor_details", json=json_content)
call_response = json.loads(call_request.text)

if call_request.status_code != 200:
    if call_request.status_code == 429:
        error = "API limit reached"
    else:
        error = call_response["error_message"]
    print(error)
else:
    for record in call_response["message"]:
        device_id = record["device_id"]
        parameter_name = record["app_parameter_name"]
        record_value = record["app_parameter_value"]
        created_time = record["created_time"]

Last updated