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.
| Protocol | Port | Address |
|---|---|---|
| WebSocket | 9911 | ws://SERVER:9911/clinet |
| HTTP | 9912 | http://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
statusof0= success- Non-0 = failure (details in
message)
Error Codes
| Code | Description | Code | Description |
|---|---|---|---|
1 | Device ID does not exist | 17 | Resource map does not exist |
2 | Device online | 18 | Failed to find picture |
3 | Group does not exist | 19 | OCR failed |
4 | Device is not online | 20 | OCR no text recognized |
5 | Screenshot failed | 21 | No coordinate parameter |
6 | No USB device bound | 22 | Unknown error |
7 | No mouse parameters | 23 | No restart coordinate point |
8 | Parameters incorrect | 24 | Key files missing |
9 | No model in general library | 25 | Failed to call interface |
10 | Configuration already exists | 26 | Plugin not connected |
11 | No model in general library | 27 | Interface call timeout |
12 | Config to delete not found | 28 | Error when calling interface |
13 | Official library no delete | 29 | AirPlay service does not exist |
14 | USB device not connected | 30 | AirPlay service not found |
15 | Must be in portrait | 31 | Already casting |
16 | Failed to send hotkey | 32 | Failed 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
| Event | Description |
|---|---|
dev_connect | Device connected |
dev_disconnect | Device disconnected |
dev_change | Device properties changed |
usb_change | USB hardware changed |
user_info | User info updated |
TIP
For the complete API with all parameters, request/response examples, and additional endpoints (groups, AirPlay, configuration), refer to the original documentation.