Basic Device API
API Reference
List all devices matched by selector
List all device information keys
Get remote control URLs for devices
Get remote control URLs for devices matched by selector
Get all devices' automatic testing configuration
Lock a device matched by selector
List all devices locked by the requesting user
Unlock a device matched by device selector
List all devices
Optional Parameters
<code class="dcode">/v0/devices?selector=<url-encoded-json></code>
, theselector
query parameter can be used as an alternative to path arguments used to filter devices.
Example
- to filter devices based on Device SKU matching "Galaxy S22", construct a JSON that looks like <code class="dcode">
{"device_skus": "Galaxy S22"}</code>
and URL encode it <code class="dcode">%7B%22device_skus%22%3A%20%22Galaxy%20S22%22%7D</code>
to pass it as an argument to the query parameter.
Response
A JSON object in the form of <code class="dcode">{"devices": [...]}</code> that has a list of device objects. Each device object has the keys listed as in the <code class="dcode">/v0/devices/keys</code> route.
An example:
If the device is using bluetooth audio there will be a key with the paired bluetooth device name:
If the device is part of an A/V box setup there will be extra information about that setup. Assume there is a device with id 1234 set up as device-under-test and it has a camera device with id 5678. The two devices would be listed as:
For each device usage indicates how the device is used inside the A/V box, it can be "device_under_test", "camera" or "audio". The devices list contains the address of related devices (so for the device-under-test that is the camera, and the other way around) and screen is the screen name used in the avbox API.
List all devices matched by selector
Devices can now be filtered using Device Selectors
Example
Response
List all device information keys
The response from /v0/devices contains a list of devices and their information in JSON format. This route lists all the keys each device object contains.
Example
Response
A JSON object in the form of {"keys": [...]} that has a list of keys.
Get all devices' automatic testing configuration
This route provides the device configuration for automated test frameworks.
Example
Response
The response is a JSON object that has an entry for each available device. The key for each entry is a device address ({device_id}@{host}) and contains information to configure automatic testing.
driver_url refers to an Appium WebDriver server, and capabilities refers to default Appium capabilities.
Example
Automation Configurations can also be filtered using Device Selectors. Please refer to API for Automation Configuration for more details.
Get remote control URLs for devices
Retrieve remote control URLs for devices that can be directly loaded into a browser to be able to view the device and interact it.
Optional Parameters
Output formats
The json format has the following structure
The value of the devices key is a list of dictionaries that each contain two keys, device_id and web_url. The device_id is an identifier for the device, and the web_url is a URL that can be used in a web browser to access the device.
The csv format is similar to json but formatted as a series of lines with the values separated by a comma
The text format returns just the url, separated by a comma for multiple devices. For a single device just that url would be returned.
or for multiple devices
Sample output for json
Example
Json output
Text output
Get url for a single device
Get remote control URLs for devices matched by selector
Device URLs can also be filtered using Device Selectors
This is a sample response
Lock a device
Lock a device matching the specified criteria.
Optional Parameters
- <code class="dcode">/v0/devices/lock?automation</code>: Lock the device as the team's automation user.
- <code class="dcode">/v0/devices/lock?idleTimeout={timeout seconds}</code>: Unlock automatically if the device is inactive for <code class="dcode">timeout seconds</code>.
Request Body
- If the request body is empty, an arbitrary device will be locked.
- If the request body contains a selector as a JSON object, a device matching the criteria in the selectors will be locked. For example: <code class="dcode">'{"hostname":"proxy-us-mvo-2.headspin.io", "model": "iPhone 6"}'</code>
Example
To lock an arbitrary device:
To lock an arbitrary device as your team's automation user:
To lock a device matching a selector:
Response
A JSON object:
- <code class="dcode">{"status": "Locked device at <hostname> with device_id <device_id>", "status_code": 200, "serial": "<device_serial>", "hostname": "<hostname>", "device_id": "<device_id>"}</code> if a device was locked successfully.
- <code class="dcode">{"status": "Failed to parse selector json. No JSON object could be decoded", "status_code": 400}</code> if the request body cannot be parsed as a JSON object. Double check to make sure that there's no syntax error.
- <code class="dcode">{"status": "Invalid keys: <list of invalid keys>", "status_code": 400}</code> if one or more keys in the selector JSON object is not a supported keys. To see available keys, use the /v0/devices/keys route.
- <code class="dcode">{"status": "No devices match.", "status_code": 403}</code> if there is no device matching the selector.
Lock a device matched by selector
Response
A JSON object:
- <code class="dcode">{"status": "Locked device at <hostname> with device_id <device_id>", "status_code": 200, "serial": "<device_serial>", "hostname": "<hostname>", "device_id": "<device_id>"}</code> if a device was locked successfully.
- <code class="dcode">{"status": "Failed to parse selector json. No JSON object could be decoded", "status_code": 400}</code> if the request body cannot be parsed as a JSON object. Double check to make sure that there's no syntax error.
- <code class="dcode">{"status": "Invalid keys: <list of invalid keys>", "status_code": 400}</code> if one or more keys in the selector JSON object is not a supported keys. To see available keys, use the <code class="dcode">/v0/devices/keys</code> route.
- <code class="dcode">{"status": "No devices match.", "status_code": 403}</code> if there is no device matching the selector.
List all devices locked by the requesting user
Example
Response
A JSON object in the form of <code class="dcode">{"devices": [...]}</code> that has a list of device objects, one for each device currently locked by the requesting user. Each device objects have the keys listed as in the <code class="dcode">/v0/devices/keys</code> route.
For example see /v0/devices.
Unlock a device
Unlock all devices matching the specified criteria, if they are locked by the requesting user. Does not unlock devices locked with the team's automation user.
Request Body
- If the request body is empty, all devices locked by the requesting user will be unlocked.
- If the request body contains a selector as a JSON object, all devices matching the criteria in the selectors will be unlocked. For example: '{"manufacturer":"samsung"}'
Example
To unlock all devices in use by the requesting user:
To unlock a device matching a selector:
Response
If there's no device matching the selector, the response is a JSON object:
- <code class="dcode">{"status": "No devices match.", "status_code": 403}</code>
If there is at lease one matching device, or no selector given, the response is a JSON object <code class="dcode">{statuses}</code> whose value is a list of devices, one for each device matching the selector. Each item in the list can have one of these values:
- <code class="dcode">{"message": "Device unlocked.", "hostname": <hostname>, "serial": <device_serial>, "success": true, "device_id": <device_id>}</code> if the device was locked to the requesting user, and now unlocked.
- <code class="dcode">{"message": "Device is already unlocked.", "hostname": <hostname>, "serial": <device_serial>, "success": false, "device_id": <device_id>}</code> if the device was already unlocked.
- <code class="dcode">{"message": "Device in use by another user.", "hostname": <hostname>, "serial": <device_serial>, "success": false, "device_id": <device_id>}</code> if the device is currently locked by another user.
Example:
Force unlock
Unlock all devices which match the specified criteria and are accessible by the requesting user, even if locked by another team member.
This uses the same request body and returns the same response as the unlock route.
Example
To unlock all accessible devices:
To unlock devices matching a selector:
Unlock a device matched by device selector
Response
If there's no device matching the selector, the response is a JSON object:
- <code class="dcode">{"status": "No devices match.", "status_code": 403}</code>
If there is at lease one matching device, or no selector given, the response is a JSON object <code class="dcode">{statuses}</code> whose value is a list of devices, one for each device matching the selector. Each item in the list can have one of these values:
- <code class="dcode">{"message": "Device unlocked.", "hostname": <hostname>, "serial": <device_serial>, "success": true, "device_id": <device_id>}</code> if the device was locked to the requesting user, and now unlocked.
- <code class="dcode">{"message": "Device is already unlocked.", "hostname": <hostname>, "serial": <device_serial>, "success": false, "device_id": <device_id>}</code> if the device was already unlocked.
- <code class="dcode">{"message": "Device in use by another user.", "hostname": <hostname>, "serial": <device_serial>, "success": false, "device_id": <device_id>}</code> if the device is currently locked by another user.
Example:
Get device notes
Response
- <code class="dcode">{"device_notes": {"<device_address>": "<notes>", ...}}</code> if device notes were retrieved successfully.
Update device notes
Request Body
- Please provide a JSON object in the request body containing the keys, <code class="dcode">device_note</code> and <code class="dcode">device_addresses</code>, like in the example below.
Response
- <code class="dcode">{"status": "success", "status_code": 200}</code> if device notes were updated successfully.
- <code class="dcode">{"status": <error message>, "status_node: 4XX}</code> if there was an error.