API Documentation

API overview (Phonefarm.some3c.com)

1.API overview (Phonefarm.some3c.com)

This interface can use http and websocket to access and interact.The websocket port number is 9911The http access port number is 9912

1.http request method

  • interface address

Server address:9912/apiExample: http://127.0.0.1:9912/api

  • Request method

post

  • Request content format

json

2.websocket request method

Using the websocket method to request the interface can get a faster response, but it is more complicated than the http request method. All request results are within the callback function.Because it is an asynchronous method, if you want to wait for the request result before proceeding to the next step, you need to convert from asynchronous to synchronous.Each interface will have a msgid field, and the server will return it unchanged after receiving it, which is used for asynchronous to synchronous conversion.

  • interface address

ws://server address:9911/clinetExample: ws://127.0.0.1:9911/clinet

  • Request content format

json All interface calls will return success or failure. A status of 0 represents success, and a status of non-0 represents failure.The failure information will be explained in the message. The following is a list of error codes.

error codes

explanation

error codes

explanation

error codes

explanation

error codes

explanation

1

Device ID does not exist

9

The general library does not have a corresponding model

17

The resource map does not exist

25

Failed to call interface

2

Device online

10

Configuration already exists

18

Failed to find picture

26

The plug-in is not connected and may not be installed.

3

group does not exist

11

The general library does not have a corresponding model

19

OCR failed

27

Interface call timeout

4

The device is not online

12

The configuration to be deleted was not found

20

OCR does not recognize text

28

Error when calling interface

5

Screenshot failed

13

The official library does not allow deletion

21

There is no corresponding coordinate parameter

29

AirPlay service does not exist

6

No USB device bound

14

USB device not connected

22

unknown error

30

AirPlay screen mirroring service not found

7

No mouse parameters

15

Must be in portrait orientation

23

No restart coordinate point

21

is already casting

8

Parameters are incorrect

16

Failed to send hotkey

24

Key files missing

32

Failed to cast screen

2.Functional interface (Phonefarm.some3c.com)


2.1 Set up device

This interface is used to set the basic information of the device, such as (usb mouse and key device), (group), (custom name). Multiple items can be set together or only one item can be set individually.The pid and vid of (usb mouse and keyboard device) can be obtained by getting the callback call of the connected USB device list and the usb device changes

  • Request parameters

  • Example 1 Set device custom name

  • Example 2 Set device grouping

  • Example 3 pid and vid of usb mouse and key device

  • Example 4 Set device mouse parameters

  • Return successfully

After the call is successful, all properties of this device will be returned.

  • Return on failure

2.2 Remove device

  • Request parameters

Delete an existing device. Online devices are not allowed to be deleted.

  • Return successfully

  • Return on failure

2.3Separate Group

  • Request parameters

  • Return successfully

  • Return on failure

2.4 Delete group

  • Request parameters

  • Return successfully

  • Return on failure

2.5 Get device list

  • Request parameters

  • Return successfully

  • Return on failure

Get group list

  • Request parameters

  • Return successfully

  • Return on failure

2.6 Get connected USB list

The (usb device) obtained by this interface refers to the special support for programming control (usb mouse and key device), and other devices will not obtain it.

  • Request parameters

  • Return successfully

  • Return on failure

2.7 Get device type and mouse parameter library list

The result after calling this interface is the currently supported mobile phone models and corresponding mouse parameters:

  • Request parameters

  • Return successfully

  • Return on failure

2.8 Take a screenshot of your device

  • Request parameters

  • Return successfully

  • Return on failure

2.9 Capture device screen in a loop

This function can only be called using (websocket). After calling, the image binary data needs to be processed in the connection (callback)If you need to stop, please send this request again and set the (stop) value to (true)If you need to modify the frequency of screenshots, please send the request again and adjust the time of (time)After the call is successful, the kernel will actively push screenshots of the device according to the set frequency. You need to get the sent data in the callback of (websocket).See the specific processing (loop interception of the device screen and return)

  • Request parameters

  • Stop looping screenshot request parameters

  • Return successfully

  • Return on failure

2.10 mouse click

  • Request parameters

  • Return successfully

  • Return on failure

2.11 mouse slide

  • Request parameters

  • Return successfully

  • Return on failure

2.12 Mouse pops up

  • Request parameters

  • Return successfully

  • Return on failure

2.13 mouse pressed

  • Request parameters

  • Return successfully

  • Return on failure

2.14 mouse movement

  • Request parameters

  • Return successfully

  • Return on failure

2.15 Mouse reset

Reset the mouse to the position of x=0 y=0

  • Request parameters

  • Return successfully

  • Return on failure

2.16 mouse wheel

  • Request parameters

  • Return successfully

  • Return on failure

2.17 Pop up all keys

  • Request parameters

  • Return successfully

  • Return on failure

2.18 Keyboard pops up

  • Request parameters

  • Return successfully

  • Return on failure

2.19 keyboard pressed

  • Request parameters

  • Return successfully

  • Return on failure

2.20 keyboard input

  • Request parameters

BACKSPACE SPACE TAB WIN ENTER SHIFT CTRL ALT ESC PAGEUP PAGEDOWN RightArrow LeftArrow DownArrow UpArrow F1 F2 F3 F4 F5 F6 F7 F8 F9 F10 F11 F12 FN

  • Return successfully

  • Return on failure

2.21 Restart the kernel

This interface only returns success, not failure.

  • Request parameters

  • Return successfully

2.22 Get the number of screen casting services

This interface only returns success, not failure.

  • Request parameters

  • Return successfully

2.23 Set the number of screen mirroring services

This interface only returns success and does not return failure. After setting, you need to restart the kernel to take effect.

  • Request parameters

  • Return successfully

2.24 Enable mouse parameter collection

Only after calling this interface can the mobile browser access the collection page normally.

  • Collection page address http://{kernel service ip address}:9911/api?fun=collection

For example: http://192.168.0.233:9911/api?fun=collection

  • Request parameters

  • Return successfully

  • Return on failure

2.25 Turn off mouse parameter collection

After calling this interface, the mobile browser cannot be opened (mouse collection page)This interface must be called to close every time mouse parameters are collected.

  • Request parameters

  • Return successfully

  • Return on failure

2.26 Mouse parameter collection

Before calling this interface, you must first call (mouse_collection_open) to enable the mouse collection interface before the mobile phone can request the collection page.Each device requires a mouse parameter for precise positioning. By default, it will automatically match from the general library. If it cannot match, you need to manually collect the mouse parameters.Because this interface is time-consuming to call, it only returns a feedback that can be collected. The specific collection results are returned in the (mouse_collection_cfg_ret) callback.This interface does not support http calls.

  • Before collecting mouse parameters, the device needs to be correctly connected to the USB device, and the collection page must be opened in full-screen mode (running from the desktop) on the mobile phone.

  • Mouse parameter collection page address http://{IP address of the kernel service}:9911/api?fun=collection

For example: http://192.168.0.233:9911/api?fun=collection

  • Request parameters

  • Return successfully

  • Return on failure

2.27 Save device mouse parameters to common library

After saving the mouse parameter configuration of the specified device to the universal library, the next time a mobile phone of the same model and version system comes online, it will automatically match this mouse parameter.

  • Request parameters

  • Return successfully

  • Return on failure

2.28 Remove mouse parameters from universal library

  • Request parameters

  • Return successfully

  • Return on failure

2.29 Send Chinese characters

To use this interface, you must bind the hotkey of the shortcut command. This interface can only be called asynchronously. The result returned synchronously only represents the success of the call. In fact, only the message that the callback returns the send_text_ok function number represents the success of the execution. Successful execution only means that the shortcut command successfully obtains Chinese characters. Characters will not be entered until 3 seconds after receiving the callback of send_text_ok.

  • Request parameters

  • Return successfully

  • Return on failure

2.30 Execute shortcut command

This interface only supports professional version calls. You must add the iMouse shortcut command to the correct phone and bind it correctly.

  • Request parameters

  • Return successfully

  • Return on failure

Function ID

Function Description

Function ID

Function Description

Function ID

Function Description

1

Get mobile photo album list

17

Turn off the flashlight (no function parameters required)

2

Transfer photos or video files from your phone’s photo album to your computer

10

Send text to phone clipboard

18

Turn on airplane mode (no function parameters required)

3

Delete mobile phone photos or video files

11

Get text from phone clipboard

19

Turn off airplane mode (no function parameters required)

4

Get the list of files in the specified directory on the mobile phone

12

Send SMS

20

Turn on cellular data (no function parameters required)

5

Transfer specified files from mobile phone to computer

13

Open url on mobile phone

21

Turn off cellular data (no function parameters required)

6

Delete specified files on mobile phone

14

Read text aloud on mobile phone

22

Turn on wireless LAN (no function parameters required)

7

Send photos or videos to mobile phone album

15

Set screen brightness

23

Turn off wireless LAN (no function parameters required)

8

Send files to the specified directory on the mobile phone

16

Turn on the flashlight (no function parameters required)

24

Get the external network IP of the mobile phone

  • Specific function parameters and return results

  • Get mobile photo album list

  • Request parameters

  • Return results

  • Transfer photos or video files from your phone’s photo album to your computer

  • Request parameters

Return resultsThe received files are stored in the iMouse installation directory\Shortcut\Media directory.

  • Delete mobile photo or video files

  • Request parameters

Return resultsnone

  • Get the list of files in the specified directory on the mobile phone

  • Request parameters

  • Return results

  • Transfer specified files from mobile phone to computer

  • Request parameters

Return resultsThe received files are stored in the iMouse installation directory\Shortcut\File directory.

  • Delete specified files on mobile phone

  • Request parameters

Return resultsnone

  • Send photos or videos to your phone’s photo album

  • Request parameters

Return resultsnone

  • Send files to the specified directory on the mobile phone

  • Request parameters

Return resultsnone

  • Send text to phone clipboard

  • Request parameters

Return resultsnone

  • Get text from phone clipboard

  • Request parameters

  • Return results

  • Open url on mobile phone

  • Request parameters

Return resultsnone

  • Set screen brightness

  • Request parameters

Return resultsnone

  • Get external network ip of mobile phone

  • Request parameters

none

  • Return results

  • Request example and return example

  • Get mobile photo album list

  • Request parameters

  • Return successfully

2.31 Find pictures

  • Request parameters

  • Return successfully

  • Return on failure

2.32 Find multiple pictures

  • Request parameters

  • Return successfully

  • Return on failure

2.33 Ocr text recognition

  • Request parameters

  • Return successfully

  • Return on failure

2.34 Find more colors

  • Request parameters

  • Return successfully

  • Return on failure

2.35 Find more colors Ex

  • Request parameters

  • Return successfully

  • Return on failure

2.36 Automatically cast screen

Before using this interface, you need to obtain the coordinate points for automatic screen projection, otherwise automatic screen projection will not work.This interface is time-consuming to call. It is recommended to use asynchronous mode.

  • Request parameters

  • Return successfully

  • Return on failure

2.37 Automatically cast to all offline phones

  • Request parameters

  • Return successfully

  • Return on failure

2.38 Disconnect screencast

  • Request parameters

  • Return successfully

2.39 Get automatic screen projection coordinate points

Before using this interface, you must keep your phone online, install the OCR and image search plug-ins, and the hardware mouse parameters are normal.This interface is time-consuming to call, so it is recommended to use asynchronous mode.

  • Request parameters

  • Return successfully

  • Return on failure

2.40 Restart USB device

Calling this interface will force both ends of the USB device to be reset. It only supports kernel version 1.2.0.3 or above and firmware of iMouse 3.0 or above hardware. To check the firmware version, go to Settings->Accessibility->Touch->Assistive Touch->Device

  • Request parameters

  • Return successfully

  • Return on failure

2.41 Switch connection hardware to automatically project the screen

After turning on the function, the screen mirroring operation will be automatically performed after connecting to the iMouse hardware, but it will not affect the manual sending of automatic screen mirroring instructions.

  • Request parameters

  • Return successfully

  • Return on failure

2.42 Get the automatic screen projection status of the connected hardware

  • Request parameters

  • Return successfully

  • Return on failure

2.43 Set screen mirroring transmission mode

[Energy Saving Mode] saves the most traffic and CPU resources, and the image is a bit laggy (a single horizontal screen game has about 5M traffic, which is suitable for 100 mobile phone users)[Normal Mode] The traffic and CPU usage are not large, and the image is slightly delayed (about 10M traffic for a single horizontal screen game is suitable for users with about 50 mobile phones)[High-performance mode] The traffic and CPU usage are large, and the image is basically no delay (a single horizontal screen game has about 20M traffic)

  • Request parameters

  • Return successfully

  • Return on failure

2.44 Get screencast transmission mode

  • Request parameters

  • Return successfully

  • Return on failure

2.45 Get the coordinate point of restarting the phone

Before using this interface, you must keep your phone online, install the OCR text recognition plug-in, and the iMouse hardware connection is normal.

  • Request parameters

  • Return successfully

  • Return on failure

2.46 restart cellphone

Before using this interface, you need to obtain the coordinate point for restarting the phone. For mobile phones of the same model, you only need to obtain it once.

  • Request parameters

  • Return successfully

  • Return on failure

3. WS callback (Phonefarm.some3c.com)


3.1 Get device list

All functional callbacks are described in the functional interface. The callbacks described here are actively notified by the server.

  • Callback content format

parameter name

Example value

Parameter Type

Parameter Description

fun

dev_connect

String

function number

data

-

Object

Return data

3.2 Device connection

This callback will be generated when the mobile phone is connected to the airplay screen mirroring service.

  • Callback content

Parameter name

Parameter description

Parameter name

Parameter description

ip

ip address of the device

width

The real width of the mobile phone screen

airhandle

The handle of the current device connected to airplay, used internally

height

The actual height of the mobile phone screen

mac

device mac address

device_name

mobile phone model

username

The name of the local definition on the device

location

usb device mouse parameters

version

mobile phone system version

state

state > 0 means online. Because this callback is online, the state is definitely not 0.

model

device internal model

rotate

screen orientation, 0 vertical screen 1 horizontal screen

deviceid

device id

vid

usb device vid

srvname

The name of the currently connected screen mirroring service

pid

usb device pid

gid

group id

name

device name (user-defined name

3.3 Device disconnected

This callback will be generated when the mobile phone is disconnected from the airplay screen mirroring service.

  • Callback content

Parameter name

Parameter description

Parameter name

Parameter description

ip

ip address of the device

width

The real width of the mobile phone screen

airhandle

The handle of the current device connected to airplay, used internally

height

The actual height of the mobile phone screen

mac

device mac address

device_name

mobile phone model

username

The name of the local definition on the device

location

usb device mouse parameters

version

mobile phone system version

state

state > 0 means online. Because this callback is online, the state is definitely not 0.

model

device internal model

rotate

screen orientation, 0 vertical screen 1 horizontal screen

deviceid

device id

vid

usb device vid

srvname

The name of the currently connected screen mirroring service

pid

usb device pid

gid

group id

name

device name (user-defined name

3.4 Mobile phone screen rotation

This callback is generated when the phone screen rotates

  • Callback content

Parameter name

Parameter description

Parameter name

Parameter description

ip

ip address of the device

width

The real width of the mobile phone screen

airhandle

The handle of the current device connected to airplay, used internally

height

The actual height of the mobile phone screen

mac

device mac address

device_name

mobile phone model

username

The name of the local definition on the device

location

usb device mouse parameters

version

mobile phone system version

state

state > 0 means online. Because this callback is online, the state is definitely not 0.

model

device internal model

rotate

screen orientation, 0 vertical screen 1 horizontal screen

deviceid

device id

vid

usb device vid

srvname

The name of the currently connected screen mirroring service

pid

usb device pid

gid

group id

name

device name (user-defined name

3.5 usb device changed

This callback is generated when the mouse-controlled USB device connected to the server changes.

  • Callback content

Parameter name

Parameter description

state

1 has a USB device connected, 0 has a USB device disconnected

vpid

The vid and pid of the disconnected or connected usb device appear

3.6 Mouse parameter collection return

  • Callback content

Parameter name

Parameter description

deviceid

Device ID

location

Mouse parameters

3.7 Callback when the mobile phone opens the collection page

  • Callback content

Parameter name

Parameter description

deviceid

Device ID

state

Status, 0 the mobile phone has entered the collection page from the browser, 1 the mobile phone has entered the collection page from the desktop icon

3.8 Loop to capture device screen and return

This callback is generated by the 9912 port connection. The callback data is binary. The first byte of the returned data 261 is the device id, and the remaining bytes are image data.

  • python decoding device id and image data

3.9 Easy language decoding device id and picture data


4. Python call (Phonefarm.some3c.com)

  • Using environment python3.9

ios_at_api.py encapsulated api interface

main.py example using pyqt

main_form.py form unit is automatically generated by pyuic through

main_form.uimain_form.ui qt interface file generated by QtDesigner ios_at_api.py needs to install the following dependent libraries

pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple/

pip install websocket-client -i https://pypi.tuna.tsinghua.edu.cn/simple/ Examples using pyqt require the following dependent libraries to be installed

pip install pyqt6 -i https://pypi.tuna.tsinghua.edu.cn/simple/

pip install pyqt6-tools -i https://pypi.tuna.tsinghua.edu.cn/simple/

pip install PyQt6-WebEngine -i https://pypi.tuna.tsinghua.edu.cn/simple/

  • simple example

  • Call the interface using http protocol

  • Use websocket protocol to call the interface

#pyqtExample with interface

  • View specific code main.py

5.Add iMouse shortcut command (Phonefarm.some3c.com)

  1. Set shortcut commands

Settings->Shortcuts->Advanced->Allow scripts, allow sharing of large amounts of data, allow direct deletion without confirmation, allow deletion of large amounts of data

  1. Download iMouse shortcuts

Open the iMouse console control window->Open the QR code->right-click to copy->send to mobile browser->open->get the shortcut command->modify the IP address in the shortcut command->run the shortcut command once->allow all

  1. Bind iMouse shortcut commands

Open the iMouse console control window -> Enter accessibility on the phone -> Assistive Touch -> Device -> iMouse4.x -> Customize more buttons -> In the iMouse console control window -> Click Send Binding Key

6.Contact us (Phonefarm.some3c.com)

Web:https://phonefarm.some3c.com

Last updated