Type something to search...

Longarm REST API

返回 longarm 文档

longarm 的 HTTP 服务器通过 /api/... 提供 REST 接口。

基础 URL

HTTP 服务器启动后,应用会显示当前可用的服务器地址。

http://192.168.1.23:8080

认证

如果启用了 Require token,请求需要包含:

Authorization: Bearer <token>

Token 缺失或无效时,longarm 会返回:

{ "error": "Missing or invalid bearer token" }

通用行为

  • POSTPUT 请求体必须是 JSON。
  • 请求体最大为 64 KiB
  • 截图响应使用 image/png
  • 批处理导出响应使用 application/zip
  • CORS 已启用。

状态和屏幕信息

  • GET /api/status
  • GET /api/screen/info

屏幕信息示例:

{ "width": 1080, "height": 2400, "density": 3.0 }

手势

POST /api/gesture/tap

{ "x": 540, "y": 1200, "duration": 50 }

POST /api/gesture/long_press

{ "x": 540, "y": 1200, "duration": 1000 }

Plus 手势:

  • POST /api/gesture/swipe
  • POST /api/gesture/pinch
  • POST /api/gesture/two_finger_swipe
  • POST /api/gesture/rotate

启用 UI 检查时,部分手势可以使用 target 代替直接坐标。

截图

GET /api/screenshot

返回 PNG 数据。

curl -H "Authorization: Bearer <token>" \
  http://<host>:<port>/api/screenshot > screenshot.png

还支持 gridSizegridColorgridWidthcoordinatesscale 等网格选项。

应用与 Intent

POST /api/app/open

{ "packageName": "com.android.settings" }

POST /api/intent/open

{
  "action": "android.intent.action.VIEW",
  "data": "https://example.com"
}

UI 检查

以下接口需要 bearer token 认证和 Allow UI inspection

  • GET /api/ui/tree
  • GET /api/ui/windows
  • POST /api/ui/find
  • POST /api/ui/wait
  • POST /api/ui/action
  • POST /api/ui/set_text
  • POST /api/ui/scroll

批处理接口

批处理任务使用 /api/batch 下的接口,包括创建、更新、运行、状态、历史记录、导出和截图下载。

任务 JSON 和运行行为见 批处理任务