API interface documentation

1. API request address

ws://127.0.0.1:22222/

2. API request structure

Both the request and response are JSON data structures, and the request parameters are of string type unless otherwise specified.

  1. Request example:

{
    "action":"pushEvent",
    "davices":"all",
    "data":{
        "type":"2"
    }
}
  1. Response example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

3. API public parameters

3.1. Request parameters

The following table shows the description of public request parameters.

3.2. Return parameters

Explain the criteria for determining success and exception returns. Also, explain the format of the returned data (such as JSON/XML).The following table shows the description of public return parameters.

4. API public response code

This article lists and explains the common response codes. If you want to know the error codes related to the business logic of a certain interface, please refer to the documentation of the interface.

5. API List Checklist

List all provided APIs

List Get device list

Get a list of all currently connected devices 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration. 3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": [
        {
            "width": 272,
            "height": 480,
            "serial": "ea85356a",
            "model": "Redmi Note 3",
            "sort": 1,
            "name": "Redmi Note 33",
            "onlySerial": "ea85356a",
            "hide": false,
            "mode": 0,
            "status": "online",
            "connectTime": 1714294839013,
            "intranetIp": "192.168.111.143",
            "sourceWidth": 1080,
            "sourceHeight": 1920
        }
    ]
}

Exception return example 1:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

UpdateDevices Update device name and number

Update the name and number of the device 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action": "updateDevices",
    "devices":"ea85356a",
    "data": {
        "sort": 1,
        "name": "Group test number one"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

Execute ADB commands

Execute adb command 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"adb",
    "devices":"all",
    "data":{
        "command":"am start -a android.intent.action.VIEW -d https://xiaowei.run"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "adb命令已执行",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

Screen capture

Screenshots are saved by default in the "D:\\ Pictures" directory on the computer and the "/sdcard/" directory on the phone 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"Screen",
    "devices":"all",
    "data":{
        "savePath":"C:\\Users\\Administrator\\Desktop"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

pointerEvent Screen Control

0 Press 1 Lift 2 Move 4 Roller up 5 Roller down 6 Slide up 7 Slide down 8 Slide left 9 Slide right 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"pointerEvent",
    "devices":"all",
    "data":{
        "type":"6",
        "x":"20",
        "y":"70"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

PushEvent Quick Operation

1 Task Management 2 Main Screen 3 Back 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"pushEvent",
    "devices":"all",
    "data":{
        "type":"2"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

writeClipBoard Send to Clipboard

Paste the text to the phone clipboard (some models may not be compatible). 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"writeClipBoard",
    "devices":"all",
    "data":{
        "content":"熊猫投屏"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

uploadFile file upload

Default upload directory:/storage/emulated/0/Download/ Album file upload directory:/storage/emulated/0/DCIM/Camera/ 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"uploadFile",
    "devices":"all",
    "data":{
        "filePath":"C:\\Users\\Administrator\\Desktop\\upload.a.txt",
        "isMedia":"0"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Find local file error",
    "data": null
}

PullFile Download files to computer

The save file path (parameter savePath) is defaulted to [D:\\ Downloads\\ serial number _ file name] when not passed. 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"pullFile",
    "devices":"all",
    "data":{
        "filePath":"/sdcard/Download/ad-link.txt",
        "savePath":"D:\\Downloads\\ad-link.txt"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

apkList App List

Get the package name and installation path of the third-party app 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"apkList",
    "devices":"all"
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": {
        "ea85356a": [            
            {
                "package": "/data/app/com.xiaowei.assistant-1",
                "apk": "com.xiaowei.assistant"
            },
            {
                "apk": "com.baidu.input_mi",
                "package": "/data/app/BaiduIME/BaiduIME"
            },
            {
                "package": "/data/app/talkback/talkback",
                "apk": "com.google.android.marvin.talkback"
            }
        ],
        "d609ef41": [
            {
                "package": "/data/app/OneKeyLockScreen/OneKeyLockScreen",
                "apk": "com.coloros.onekeylockscreen"
            },
            {
                "package": "/data/app/com.nearme.note-UKiAh14ZDIXnoci_NYkTcQ==",
                "apk": "com.nearme.note"
            },
            {
                "apk": "com.nearme.play",
                "package": "/data/app/com.nearme.play-9ci1OrRtCU7bK659l64Pyw=="
            }
        ]
    }
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

InstallApk Installation APK

Install the app, some brands of phones may prompt for security verification 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"installApk",
    "devices":"all",
    "data":{
        "filePath":"D:\\Downloads\\tqyyapkazb.apk"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Find local file error",
    "data": null
}

UninstallApk Uninstall APK

Uninstall apk 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"uninstallApk",
    "devices":"d609ef41",
    "data":{
        "apk":"cn.androidfun.apkfetch"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

StartApk launches applications

Launch the app 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"startApk",
    "devices":"d609ef41",
    "data":{
        "apk":"com.coloros.weather"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

stopApk stop application

Close the app 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"stopApk",
    "devices":"d609ef41",
    "data":{
        "apk":"com.coloros.weather"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

imeList Get a list of input methods

Get the list of input methods in the current phone 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"imeList",
    "devices":"all"
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": {
        "ea85356a": [
            "com.sohu.inputmethod.sogou.xiaomi/.SogouIME",
            "com.baidu.input_mi/.ImeService",
            "com.xiaowei.assistant/.keyboard.XwIME",
            "com.android.xwkeyboard/.XwIME"
        ],
        "d609ef41": [
            "com.sohu.inputmethod.sogouoem/.SogouIME",
            "com.android.xwkeyboard/.XwIME"
        ]
    }
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

installInputIme Install the projection input method

Install the projection keyboard. This input method is required for text input. Generally, it will be automatically installed after connecting to a mobile phone and does not need to be called. Installation is silent, but some brands of mobile phones may pop up installation verification, which needs to be completed before installation. 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"installInputIme",
    "devices":"all"
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

selectIme Select input method

Select the input method used by the mobile phone 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"selectIme",
    "devices":"ea85356a",
    "data":{
        "ime":"com.sohu.inputmethod.sogou.xiaomi/.SogouIME"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

inputText input text

It needs to be switched to a screen mirroring keyboard and called in an inputtable scene. 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"inputText",
    "devices":"ea85356a",
    "data":{
        "content":"熊猫投屏"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

getTags Get all tags

Get all current tags and their device serial numbers. In the software, tags are groupings 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"getTags"
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": [
        {
            "name": "全部手机",
            "ids": [
                "d609ef41",
                "ea85356a"
            ],
            "ident": "all"
        },
        {
            "name": "未标签手机",
            "ids": [
                "abec10cd",
                "d609ef41"
            ],
            "ident": "notTag"
        },
        {
            "name": "大话西游功能测试",
            "ids": []
        },
        {
            "name": "应用启停测试",
            "ids": []
        }
    ]
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

addTag Create a tag

Create label groups 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"addTag",
    "data":{
        "name":"测试一组"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

UpdateTag Modify the tag

Modify the tag name, "all phones" and "untagged phones" are the default groups and cannot be modified. 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"updateTag",
    "data":{
        "oldName":"测试一组",
        "name":"开发一组"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

removeTag

Delete labels. "All phones" and "Unlabeled phones" are the default groups and cannot be deleted. 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"removeTag",
    "data":{
        "name":"测试一组"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

addTagDevice Add device to tag group

Add devices to the label 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"addTagDevice",
    "devices":"ea85356a",
    "data":{
        "name":"测试一组"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

removeTagDevice Remove devices under the label

Remove device from label 1 Request parameters

2 Sample requests Here is an example of a request under a general configuration.

{
    "action":"removeTagDevice",
    "devices":"ea85356a",
    "data":{
        "name":"测试一组"
    }
}

3 Return parameters

4 Return to example Here is an example of a request under a general configuration. Normal return example:

{
    "code": 10000,
    "message": "SUCCESS",
    "data": null
}

Exception return example 1:

{
    "code": 10001,
    "message": "Invalid action",
    "data": null
}

Exception return example 2:

{
    "code": 10001,
    "message": "Request parameter error",
    "data": null
}

6. ADB command list

Use Ctrl + F shortcut to quickly find the command you need ^_^

  1. Functional class

  1. Button type

7. Xiaomi MIUI ADB optimization command

Last updated