Get a list of your devices
curl -X GET "https://api.devicehub.com/v1/devices" \
-H
Get event history for a specific device
curl -X GET "https://api.devicehub.com/v1/devices/DEMO-1000/history?limit=5" \
-H
Send a command to a device
curl -X POST "https://api.devicehub.com/v1/devices/DEMO-1000/commands" \
-H \
-H \
-d '{
"command": "get.status",
"parameters": {}
}'
Get a list of your devices
const apiKey = '<YOUR_API_KEY>';
const url = 'https://api.devicehub.com/v1/devices';
fetch(url, {
method: 'GET',
headers: {
'Authorization': `Bearer ${apiKey}`
}
});
Get event history for a specific device
const deviceId = 'DEMO-1000';
fetch(`https://api.devicehub.com/v1/devices/${deviceId}/history?limit=5`, {
headers: { 'Authorization': `Bearer ${apiKey}` }
});
Send a command to a device
const data = {
command: 'get.status',
parameters: {}
};
fetch(`https://api.devicehub.com/v1/devices/${deviceId}/commands`, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiKey}`,
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
});
Get a list of your devices
import requests
api_key = "<YOUR_API_KEY>"
url = "https://api.devicehub.com/v1/devices"
headers = {"Authorization": f"Bearer {api_key}"}
response = requests.get(url, headers=headers)
print(response.json())
Get event history for a specific device
device_id = "DEMO-1000"
url = f"https://api.devicehub.com/v1/devices/{device_id}/history?limit=5"
response = requests.get(url, headers=headers)
print(response.json())
Send a command to a device
url = f"https://api.devicehub.com/v1/devices/{device_id}/commands"
payload = {"command": "get.status", "parameters": {}}
response = requests.post(url, headers=headers, json=payload)
print(response.json())