GET /app/devices
URL requires a body with the following format (Items in bold are required):
No body as this endpoint uses GET requests
{
"count": *number of devices,
"devicelist": [
*list of device ID Strings
]
}
Python example to get list of Device IDs
#!/usr/bin/python3
# API_Get_Devices.py
#
# Retrieve list of user's Device IDs stored in EDG database
# These device ID's are required to POST/GET data under specific devices
# This example is built on top of the API Login Example
#
# Copyright (c) 2021-2023 Engineering Design Group, LLC. All Rights Reserved.
#
# <variable_name> represents value specific to user
import requests
import json
#Need an access token to access this API endpoint
import API_Login_Example
def getDeviceId(accessToken = ""):
#retrieve access token if user does not provide one
if accessToken == "":
accessToken = API_Login_Example.getToken(<user_username>,
<user_password>,
<client_ID>)
#generate URL for POST request
baseUrl = <API_URL>
endpointAddress = "/app/devices"
deviceIdUrl = baseUrl + endpointAddress
#create header and body to send to API
authHeader={
"Authorization": "Bearer " + accessToken,
"Content-Type": "application/json"
}
#retrieve Device ID list using GET request
response = requests.get(deviceIdUrl,
headers = authHeader,
verify = True)
#display API response code
print("Device ID: ", response)
DeviceList = response.json()
DeviceIds = DeviceList['devicelist']
return DeviceIds
def main():
print("Retrieving list of device ID's...")
device_IDs = getDeviceId()
#display list of device ID's accessible by user
print("Device IDs: ", device_IDs)
if __name__ == "__main__":
main()