REST API
Using Upswift REST API, users can pull information of their devices fleet to make different actions such as schedule update deployments, send log files, change device name, etc..
Each device can send up to 3 API calls in a minute. If you reach the limit, you will receive an appropriate response code. Please check the response codes and send no more calls than the limit. Otherwise, your device may get banned for API calls. All calls require user_token and some of them require device_token.
The user_token can be found at the Settings category on Upswift dashboard under your account. The device_token can be found in the file /etc/upswift/service/settings.json on devices with agent version under 5.4, for devices with agent 5.4 and above, you can run the agent with the flag --print-token to receive the device token: /etc/upswift/service/UpswiftAgent --print-token
Here is a ready-to-use piece of code to pull user_token and device_token automatically with a Python script from the device (on devices with agent under version 5.4):
1
import json
2
import requests
3
4
UPSWIFT_SETTINGS_FILE = '/etc/upswift/service/settings.json'
5
6
#Pull Upswift tokens
7
with open(UPSWIFT_SETTINGS_FILE) as json_file:
8
data = json.load(json_file)
9
10
#Upswift tokens
11
user_token = data['user_token']
12
device_token = data['device_token']
Copied!
For devices with Upswift agent version 5.4 and above, you will have to get the user_token from Upswift dashboard and the device_token by running the agent on the device with the flag --print-token.
All endpoints' payload data is in JSON format.
Last modified 2mo ago
Copy link