Skip to content

Phone Farm API Documentation Recent

API for phonefarm.some3c.com - the box phone farm system.

1. API Overview

This interface uses http and websocket for access.

ProtocolPortAddress
WebSocket9911ws://SERVER:9911/clinet
HTTP9912http://SERVER:9912/api

HTTP Request

  • Method: POST
  • Content format: json

WebSocket Request

Using WebSocket provides faster response but requires async-to-sync conversion. Each interface has a msgid field returned as-is for this purpose.

Response Format

  • status of 0 = success
  • Non-0 = failure (details in message)

Error Codes

CodeDescriptionCodeDescription
1Device ID does not exist17Resource map does not exist
2Device online18Failed to find picture
3Group does not exist19OCR failed
4Device is not online20OCR no text recognized
5Screenshot failed21No coordinate parameter
6No USB device bound22Unknown error
7No mouse parameters23No restart coordinate point
8Parameters incorrect24Key files missing
9No model in general library25Failed to call interface
10Configuration already exists26Plugin not connected
11No model in general library27Interface call timeout
12Config to delete not found28Error when calling interface
13Official library no delete29AirPlay service does not exist
14USB device not connected30AirPlay service not found
15Must be in portrait31Already casting
16Failed to send hotkey32Failed to cast screen

2. Functional Interface

2.1 Set Up Device

Set basic device info: USB mouse/keyboard device, group, custom name.

json
{
   "fun": "set_dev",
   "msgid": 0,
   "data": {
     "deviceid": "F4:0F:24:D8:42:24",
     "vid": "520A",
     "pid": "2412",
     "gid": "1732525476",
     "name": "custom name"
   }
}

TIP

The pid and vid of USB devices can be obtained from the connected USB device list callback and the USB device changes callback.

2.2 Get Device List

json
{
   "fun": "get_dev_list",
   "msgid": 0,
   "data": {}
}

2.3 Delete Device

json
{
   "fun": "del_dev",
   "msgid": 0,
   "data": {
     "deviceid": "F4:0F:24:D8:42:24"
   }
}

2.4 Mouse Click

json
{
   "fun": "mouse_click",
   "msgid": 0,
   "data": {
     "deviceid": "F4:0F:24:D8:42:24",
     "x": 100,
     "y": 200,
     "button": 1
   }
}

2.5 Mouse Swipe

json
{
   "fun": "mouse_swipe",
   "msgid": 0,
   "data": {
     "deviceid": "F4:0F:24:D8:42:24",
     "direction": "up",
     "len": 0.8
   }
}

2.6 Get Connected USB List

json
{
   "fun": "get_usb_list",
   "msgid": 0,
   "data": {}
}

2.7 Keyboard Input

json
{
   "fun": "key_sendkey",
   "msgid": 0,
   "data": {
     "deviceid": "F4:0F:24:D8:42:24",
     "key": "hello world"
   }
}

2.8 Screenshot

json
{
   "fun": "screenshot",
   "msgid": 0,
   "data": {
     "deviceid": "F4:0F:24:D8:42:24",
     "save_path": "D:\\screenshots\\"
   }
}

2.9 OCR Text Recognition

json
{
   "fun": "ocr",
   "msgid": 0,
   "data": {
     "deviceid": "F4:0F:24:D8:42:24"
   }
}

2.10 Find Image

json
{
   "fun": "find_image",
   "msgid": 0,
   "data": {
     "deviceid": "F4:0F:24:D8:42:24",
     "img_list": ["D:\\images\\target.bmp"],
     "similarity": 0.85
   }
}

3. Callback Events

EventDescription
dev_connectDevice connected
dev_disconnectDevice disconnected
dev_changeDevice properties changed
usb_changeUSB hardware changed
user_infoUser info updated

TIP

For the complete API with all parameters, request/response examples, and additional endpoints (groups, AirPlay, configuration), refer to the original documentation.

Some3C Phone Farm Documentation