Skip to main content

Device Management

Endpoints for managing Android devices, including registration, pairing, and device information.

Device Discovery

GET /api/devices/scan

Scans for connected Android devices via ADB.

Response:

[
{
"id": "emulator-5554",
"model": "sdk_gphone64_arm64",
"manufacturer": "Google",
"androidVersion": "14",
"apiLevel": 34,
"isEmulator": true
}
]

GET /api/devices/registered

Gets all registered devices from the database.

Response:

[
{
"id": "device-123",
"serialNumber": "emulator-5554",
"model": "Pixel 6",
"manufacturer": "Google",
"androidVersion": "14",
"fingerprint": "device-fingerprint-hash",
"registeredAt": "2024-01-01T00:00:00.000Z"
}
]

GET /api/devices/all-registered

Gets all registered devices with additional metadata.

Response: Similar to /api/devices/registered but includes more device details.

Device Information

GET /api/devices/:deviceId/fingerprint

Gets the unique fingerprint for a device.

Parameters:

  • deviceId: Device identifier

Response:

{
"deviceId": "device-123",
"fingerprint": "unique-device-hash",
"generatedAt": "2024-01-01T00:00:00.000Z"
}

GET /api/devices/:deviceId/apps

Gets the list of installed applications on a device.

Parameters:

  • deviceId: Device identifier

Response:

[
{
"packageName": "com.android.chrome",
"appName": "Chrome",
"versionName": "119.0.6045.66",
"versionCode": 604506603,
"isSystemApp": false
}
]

GET /api/devices/:deviceId/coordinates

Gets device coordinate mappings for UI automation.

Parameters:

  • deviceId: Device identifier

Response:

{
"deviceId": "device-123",
"width": 1080,
"height": 2400,
"density": 440,
"normalizedWidth": 1080,
"normalizedHeight": 2400
}

GET /api/devices/:deviceId/coordinates/:flowId

Gets coordinates specifically for a flow.

Parameters:

  • deviceId: Device identifier
  • flowId: Flow identifier

Response:

{
"deviceId": "device-123",
"flowId": "flow-456",
"coordinates": {
"width": 1080,
"height": 2400,
"density": 440
},
"cachedElements": [
{
"id": "button-1",
"x": 540,
"y": 1200,
"confidence": 0.95
}
]
}

Device Pairing

POST /api/devices/pair

Pairs a device for wireless ADB connection.

Request Body:

{
"ip": "192.168.1.100",
"port": 5555,
"pairingCode": "123456"
}

Response:

{
"success": true,
"deviceId": "device-123",
"message": "Device paired successfully"
}

POST /api/devices/connect-wireless

Connects to a wireless ADB device.

Request Body:

{
"ip": "192.168.1.100",
"port": 5555
}

Response:

{
"success": true,
"deviceId": "device-123",
"message": "Device connected wirelessly"
}

POST /api/devices/register-with-fingerprint

Registers a device using its fingerprint.

Request Body:

{
"serialNumber": "emulator-5554",
"fingerprint": "device-hash"
}

Response:

{
"success": true,
"device": {
"id": "device-123",
"serialNumber": "emulator-5554",
"registeredAt": "2024-01-01T00:00:00.000Z"
}
}

POST /api/devices/database

Manages device database operations (create, update, delete).

Request Body:

{
"action": "create",
"device": {
"serialNumber": "emulator-5554",
"model": "Pixel 6",
"manufacturer": "Google"
}
}

POST /api/devices/ensure-registered

Ensures a device is registered, creating it if necessary.

Request Body:

{
"serialNumber": "emulator-5554",
"fingerprint": "device-hash"
}

Device Control

POST /api/devices/:deviceId/launch-app

Launches an application on the device.

Parameters:

  • deviceId: Device identifier

Request Body:

{
"packageName": "com.android.chrome",
"activity": "com.google.android.apps.chrome.Main"
}

Response:

{
"success": true,
"message": "App launched successfully"
}

POST /api/devices/:deviceId/recalculate-coordinates

Recalculates coordinate mappings for the device.

Parameters:

  • deviceId: Device identifier

Response:

{
"success": true,
"coordinates": {
"width": 1080,
"height": 2400,
"density": 440
}
}

POST /api/devices/:targetDeviceId/assign-flows

Assigns flows to a specific device.

Parameters:

  • targetDeviceId: Device identifier

Request Body:

{
"flowIds": ["flow-1", "flow-2", "flow-3"]
}

Response:

{
"success": true,
"assignedFlows": 3,
"message": "Flows assigned successfully"
}

Device Actions

POST /api/device/screenshot

Captures a screenshot from a device.

Request Body:

{
"deviceId": "device-123",
"saveToFile": true
}

Response:

{
"success": true,
"screenshotPath": "/path/to/screenshot.png",
"timestamp": "2024-01-01T00:00:00.000Z"
}

POST /api/device/input

Sends input commands to a device.

Request Body:

{
"deviceId": "device-123",
"action": "tap",
"x": 540,
"y": 1200
}

Response:

{
"success": true,
"message": "Input sent successfully"
}

GET /api/device/screenshot-data/:deviceId

Gets screenshot data for a specific device.

Parameters:

  • deviceId: Device identifier

Response: Base64 encoded image data or image stream.

Device Removal

DELETE /api/devices/:deviceId

Removes a device from the system.

Parameters:

  • deviceId: Device identifier

Response:

{
"success": true,
"message": "Device removed successfully"
}