> For the complete documentation index, see [llms.txt](https://doc.some3c.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://doc.some3c.com/panda-classic/api-documentation.md).

# API Documentation

API endpoints and network protocols for automating device interactions in legacy Panda Classic installations.

WebSocket API is a common and universal API interface of HTTP protocol, supporting various language calls, such as: key wizard, easy language, C++, Python, Html, Vue, Node.js and so on.

* Panda Classic WebSocket API address: ws\://127.0.0.1:33332
* WebSocket Online Test: <https://wstool.js.org/>

## 1.Obtain all device information

Request:

{% code collapsedlinecount="10" %}

```json
{ "action":"list" }
```

{% endcode %}

Response:

{% code collapsedlinecount="10" %}

```json
{
    "StatusCode": 200,
    "result": [
        {
            "deviceId": "ga7d65ylnj6xinhm",
            "name": "ga7d65ylnj6xinhm",
            "no": 1,
            "groupNames": ["group1", "group2"]
        },
        {
            "deviceId": "VBJDU18B14001987",
            "name": "VBJDU18B14001987",
            "no": 24,
            "groupNames": ["group1"]
        }
    ]
}
```

{% endcode %}

## 2.Screenshot

Request:

{% code collapsedlinecount="10" %}

```json
{
    "action": "screen",
    "comm": {
        "deviceIds": "all",
        "savePath": "d:/quickmirror",
        "onlyDeviceName": 1,
        "customName": "test"
    }
}
```

{% endcode %}

* deviceIds: `"all"` means all devices, or devices can be specified by passing a comma-separated deviceId, for example `"ga7d65ylnj6xinhm, VBJDU18B14001987"`
* onlyDeviceName: Whether to directly use the device serial number as the screenshot file name
  * 1 means that the screenshot file name only has the device serial number (for example `ga7d65ylnj6xinhm.png` )
  * 0 indicates that the screenshot file name contains the device number and screenshot time (for example `1_ga7d65ylnj6xinhm_20240707_114500_096 .png` )
* customName: Specify the name used for the screenshot (no suffix is required), if this parameter is not empty, the name will be used as the screenshot name first, and customName can only be set when there is only one device in deviceIds
* Note: If it is a wireless connection, the `:` and `.` in the device serial number will be replaced by `_` (for example, the device `192.168.2.109:5555` screenshot file name is `1_192_168_2_109_5555_20240707_114919_656 .png` )

Response:

{% code collapsedlinecount="10" %}

```json
{
    "StatusCode": 200,
    "result": "OK"
}
```

{% endcode %}

## 3.Screen control

Request:

{% code collapsedlinecount="10" %}

```json
{
    "action": "PointerEvent",
    "comm": {
        "deviceIds": "all",
        "mask": "0",
        "x": "0.5",
        "y": "0.5",
        "endx": "0",
        "endy": "0",
        "delta": "0"
    }
}
```

{% endcode %}

* deviceIds: `"all"` means all devices, or devices can be specified by passing a comma-separated deviceId, for example `"ga7d65ylnj6xinhm, VBJDU18B14001987"`
* Mask: Event type: 0 press, 1 move, 2 release, 3 right mouse button (return), 4 scroll up, 5 scroll down, 6 slide up, 7 slide down, 8 slide left, 9 slide right
* X, y: event coordinates, pass percentage, range is 0-1
* Endx, endy: End coordinates. These two parameters are only needed for up, down, left, and right sliding events. Other events do not need to pass them
* Delta: The amplitude of the scroll wheel event, the range is an integer greater than 0, the larger the value, the greater the scroll wheel rolling amplitude, only the scroll wheel event needs this parameter, other events do not need to pass

Response:

{% code collapsedlinecount="10" %}

```json
{
    "StatusCode": 200,
    "result": "OK"
}
```

{% endcode %}

Example:\
Swipe up screen

{% code collapsedlinecount="10" %}

```json
//First, execute the command: mask=0, x=0.5, y=0.5, starting from the center.
{
    "action": "PointerEvent",
    "comm": {
        "deviceIds": "all",
        "mask": "0",
        "x": "0.5",
        "y": "0.5",
        "endx": "0",
        "endy": "0",
        "delta": "0"
    }
}
//Execute "move mask=1" to move to the 0.2 position. You can execute multiple "move" commands before releasing the button; doing so will result in dragging.  
{
    "action": "PointerEvent",
    "comm": {
        "deviceIds": "all",
        "mask": "1",
        "x": "0.5",
        "y": "0.2",
        "endx": "0",
        "endy": "0",
        "delta": "0"
    }
}
//Finally, release `mask=2 x y` and pass the final position.
{
    "action": "PointerEvent",
    "comm": {
        "deviceIds": "all",
        "mask": "2",
        "x": "0.5",
        "y": "0.2",
        "endx": "0",
        "endy": "0",
        "delta": "0"
    }
}
```

{% endcode %}

## 4.Get clipboard content

Request:

{% code collapsedlinecount="10" %}

```json
{
    "action": "getclipboard",
    "comm": {
        "deviceIds": "8318fc66"
    }
}
```

{% endcode %}

* DeviceIds: This command does not support multiple phone deviceIds

Response:

{% code collapsedlinecount="10" %}

```json
{
    "StatusCode": 200,
    "result": "Shear Plate Test"
}
```

{% endcode %}

## 5.Send to clipboard

Request:

{% code collapsedlinecount="10" %}

```json
{
    "action": "writeclipboard",
    "comm": {
        "deviceIds": "all",
        "content": "Hi, panda"
    }
}
```

{% endcode %}

* deviceIds: `"all"` means all devices, or devices can be specified by passing a comma-separated deviceId, for example `"ga7d65ylnj6xinhm, VBJDU18B14001987"`

Response:

{% code collapsedlinecount="10" %}

```json
{
    "StatusCode": 200,
    "result": "OK"
}
```

{% endcode %}

## 6.Execute ADB commands

Request:

{% code collapsedlinecount="10" %}

```json
{
    "action": "adb",
    "comm": {
        "command": "am start -a android.intent.action. VIEW -d https://SOME 3C Automation",
        "deviceIds": "ga7d65ylnj6xinhm"
    }
}
```

{% endcode %}

* deviceIds: `"all"` means all devices, or devices can be specified by passing a comma-separated deviceId, for example `"ga7d65ylnj6xinhm, VBJDU18B14001987"`

Response:

{% code collapsedlinecount="10" %}

```json
{
    "StatusCode": 200,
    "result": {
        "ga7d65ylnj6xinhm": [
            "Starting: Intent { act=android.intent.action. VIEW dat=https://SOME 3C Automation/... }"
        ]
    }
}
```

{% endcode %}

## 7.Execute ADB bat

Request：\
Execute custom bat：

{% code collapsedlinecount="10" %}

```json
{
    "action": "ExecuteBat",
    "comm": {
        "deviceIds": "ga7d65ylnj6xinhm",
        "filePath" :"C:\\Scripts\\test.bat"
    }
}
```

{% endcode %}

* deviceIds: `"all"` means all devices, or devices can be specified by passing a comma-separated deviceId, for example `"ga7d65ylnj6xinhm, VBJDU18B14001987"`

Response：

{% code collapsedlinecount="10" %}

```json
{
    "StatusCode": 200,
    "result": "OK"
}
```

{% endcode %}

## 8.Execute AutoX.js script

Request：\
Execute custom AutoX.js：

{% code collapsedlinecount="10" %}

```json
{
    "action": "ExecuteAutoJs",
    "comm": {
        "deviceIds": "ga7d65ylnj6xinhm",
        "filePath" :"C:\\Scripts\\test.js"
    }
}
```

{% endcode %}

Stop custom AutoX.js：

{% code collapsedlinecount="10" %}

```json
{
    "action": "StopAutoJs",
    "comm": {
        "deviceIds": "ga7d65ylnj6xinhm",
        "filePath" :"C:\\Scripts\\test.js"
    }
}
```

{% endcode %}

* deviceIds: `"all"` means all devices, or devices can be specified by passing a comma-separated deviceId, for example `"ga7d65ylnj6xinhm, VBJDU18B14001987"`

Response：

{% code collapsedlinecount="10" %}

```json
{
    "StatusCode": 200,
    "result": "OK"
}
```

{% endcode %}
