Agent API
This REST API enables connecting embedded RTOS, windows CE or any other edge-device to Upswift platform.
post
https://api.upswift.io/v1/agent/
register_device
Register Device
If you receive status code 350, it means the device has been deleted from the dashboard. You must STOP sending Device Registration and Device Status calls.
Example
Python
1
import json
2
import requests
3
4
json_content = {'user_token': 'XXXXXXXXXXXXXXX',
5
'device_identifier': ['aa:bb:cc:dd:ee:11', 'aa:bb:cc:dd:ee:22'],
6
'project_name': 'TestProject',
7
'device_os': 'Windows CE',
8
'upswift_version': 'AgentAPI-v1',
9
'device_name': 'MyDevice1',
10
'device_group': 'Test',
11
'software_version': '1.0'}
12
13
call_request = requests.post("https://api.upswift.io/v1/agent/register_device", json=json_content)
14
call_response = json.loads(call_request.text)
15
16
if call_request.status_code != 200:
17
if call_request.status_code == 429:
18
error = "API limit reached"
19
elif call_request.status_code == 350:
20
### DEVICE IS DELETED
21
else:
22
error = call_response["message"]
23
print(error)
24
else:
25
device_token = call_response["message"]["device_token"]
26
Copied!
get
https://api.upswift.io/v1/agent/
project_parameters
Project Parameters
Example
Python
1
import json
2
import requests
3
4
json_content = {'device_token': 'XXXXXXXXXXXXXXX'}
5
6
call_request = requests.get("https://api.upswift.io/v1/agent/project_parameters", json=json_content)
7
call_response = json.loads(call_request.text)
8
9
if call_request.status_code != 200:
10
if call_request.status_code == 429:
11
error = "API limit reached"
12
else:
13
error = call_response["message"]
14
print(error)
15
else:
16
status_timeout = call_response["message"]["status_timeout"]
17
Copied!
post
https://api.upswift.io/v1/agent/
device_status
Device Status
If you receive status code 301, it means that the Project Parameters have been changed. You have to call the Project Parameters call as soon as possible.
Example
Python
1
import json
2
import requests
3
4
json_content = {'device_token': 'XXXXXXXXXXXXXXX',
5
'ram': 33,
6
'cpu': 12,
7
'disk_usage_total': 1200,
8
'disk_usage_current': 180,
9
'process_monitor': {"mysql": true,
10
"my_app": false}}
11
12
call_request = requests.post("https://api.upswift.io/v1/agent/device_status", json=json_content)
13
call_response = json.loads(call_request.text)
14
15
if call_request.status_code != 200:
16
if call_request.status_code == 429:
17
error = "API limit reached"
18
elif call_request.status_code == 301:
19
### NEW PROJECT PARAMETERS
20
else:
21
error = call_response["message"]
22
print(error)
23
Copied!