HTTP API reference
Every iPhone running ketec serves this HTTP API on the local network. Machine-readable version: /api/openapi.json (OpenAPI 3.1, 99 operations).
Every phone running ketec hosts its own HTTP server. The address (phone IP and port) is shown on the App status page; the default port is 9800. Use phone-ip in examples as a placeholder for that address.
ketec runs in one of two modes:
- Agent mode: no extra hardware; touches, typing and UI-tree reading are injected through the iOS system testing/automation service.
- HID mode: an ESP32-S3 USB HID device plugged into the phone performs touches and key presses.
/api/control/* and /api/source are for Agent mode (in HID mode most /api/control/* calls are forwarded to the HID channel; w3cActions is Agent-only). /api/hid/* is for HID mode and needs the ESP32-S3 device for touch and key input. Each operation lists its modes in x-modes.
Conventions:
- Most endpoints are
GETwith query parameters; the server does not check the HTTP method. Endpoints documented asPOSTread a request body (JSON or binary). - Query values must be URL-encoded;
+decodes to a space, so send a literal plus as%2B. - Coordinates are physical screen pixels, the same as the screenshot pixels.
- Responses are JSON shaped like
{"success": bool, "data": ..., "message"?: string, "reason"?: string}unless stated otherwise (images, streams, file downloads, the log endpoints).message/reasonare human-readable (usually Chinese) and not stable; checksuccessand documented fields. - Missing or invalid parameters return HTTP 400; unknown paths return 404
{"success": false, "reason": "Not Found"}. Many action failures still use HTTP 200 withsuccess: false. - If the device license is not valid, most endpoints return
{"success": false, "error": "license", "message": ...}.
Security: there is no authentication. Anyone who can reach the port can control the phone, read the clipboard and files, and delete photos. Use it only on a trusted local network and never expose the port to the internet.
The /v1/heartbeat operation (tag License Service) runs on the cloud license service https://api.ketec.top, not on the phone; it is listed for reference.
Base URL: http://{phoneIp}:{port} (default port 9800)
Device
Device status, screenshots, installed apps, lock state, brightness, volume and run-mode switching.
GET /api/status — Get app and device status
Returns device identity, screen geometry, battery, current run mode, Agent/HID availability, script and recording state. The object also contains extra diagnostic fields that are not part of the stable contract.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/status"
Response:
{
"success": true,
"data": {
"apiVersion": "330v223",
"appName": "ketec",
"appBundleId": "top.ketec.app",
"appVersion": "1.0.0",
"appBuildNumber": 330.223,
"bundleVersion": "330.223",
"appNo": "",
"deviceName": "iPhone",
"deviceModel": "iPhone13,2",
"osVersion": "16.1.1",
"deviceIp": "phone-ip",
"deviceId": "<device-id>",
"serverDeviceId": "<server-device-id>",
"udid": "<udid>",
"ecid": "<ecid>",
"orientation": "PORTRAIT",
"screenInfo": {
"width": 1170,
"height": 2532,
"scale": 3,
"logicWidth": 390,
"logicHeight": 844
},
"batteryInfo": {
"level": 87,
"isCharging": true
},
"volume": 0.5,
"brightness": 0.6,
"isLocked": false,
"selectedRunMode": "agent",
"agentConnected": true,
"agentAvailable": true,
"isHidConnected": false,
"hidModel": "",
"hidVersion": "",
"isRun": false,
"isShowUI": false,
"isRecording": false,
"isBroadcastConnected": false,
"isMirrorLive": false,
"isAuth": true,
"isLogin": true,
"isDebugMode": false,
"isVolumeControlEnabled": false,
"uptime": 86400,
"scriptModules": [
"appleOcr",
"device",
"action",
"hid",
"file",
"http",
"config",
"system",
"media",
"ime",
"app",
"node"
]
}
}GET /api/apps — List installed apps
Returns user-installed apps. Each item carries appName, bundleIdentifier and bundleVersion (plus the legacy aliases name and bundleId).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/apps"
Response:
{
"success": true,
"data": [
{
"appName": "Settings",
"bundleIdentifier": "com.apple.Preferences",
"bundleVersion": "1.0",
"name": "Settings",
"bundleId": "com.apple.Preferences"
}
]
}GET /api/isLocked — Check whether the screen is locked
Returns the lock state. Read locked together with source (which detection level produced the answer: notify, keybag, display or none); data carries the same boolean for compatibility.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/isLocked"
Response:
{
"success": true,
"data": false,
"locked": false,
"source": "notify",
"diag": {
"notify": 0,
"keybag": 1,
"displayPower": "unavailable"
}
}GET /api/screenshot — Take a screenshot (binary image)
Returns the current screen as JPEG or PNG (Content-Type tells which). Image pixels match the device's physical resolution, so coordinates measured on it can be passed to click endpoints directly.
Modes: agent, hid
Parameters:
method(query, string; default "auto"; one of auto, xct, broadcast, replaykit, render, shortcuts): Capture channel. auto tries xct, broadcast, replaykit, render in order. xct = system test service (Agent mode); broadcast = latest frame of the running screen broadcast; replaykit = in-process ReplayKit; render = ketec's own window only; shortcuts = helper Shortcut via the HID device (never chosen by auto). An explicitly chosen channel never falls back.meta(query, integer; default 0; one of 0, 1): When 1, return only a JSON receipt (method, size, dimensions) instead of the image.
Example:
curl "http://phone-ip:9800/api/screenshot"
Response: image/jpeg
GET /api/screenshotBase64 — Take a screenshot (Base64 JSON)
Same capture as /api/screenshot, returned as JSON with the image Base64-encoded in data and its MIME type in contentType.
Modes: agent, hid
Parameters:
method(query, string; default "auto"; one of auto, xct, broadcast, replaykit, render, shortcuts): Capture channel. auto tries xct, broadcast, replaykit, render in order. xct = system test service (Agent mode); broadcast = latest frame of the running screen broadcast; replaykit = in-process ReplayKit; render = ketec's own window only; shortcuts = helper Shortcut via the HID device (never chosen by auto). An explicitly chosen channel never falls back.meta(query, integer; default 0; one of 0, 1): When 1, return only a JSON receipt (method, size, dimensions) instead of the image.
Example:
curl "http://phone-ip:9800/api/screenshotBase64"
Response:
{
"success": true,
"method": "xct",
"bytes": 412345,
"w": 1170,
"h": 2532,
"format": "jpeg",
"blank": false,
"elapsedMs": 180,
"needsUserAction": false,
"contentType": "image/jpeg",
"data": "/9j/4AAQSkZJRgABAQ..."
}GET /api/takeMeToFront — Bring ketec to the foreground
Switches the ketec app itself to the foreground. Returns alreadyFront=true if it already is.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/takeMeToFront"
Response:
{
"success": true,
"data": {
"bundleId": "top.ketec.app",
"alreadyFront": true
}
}GET /api/getScreenBrightness — Get screen brightness
Returns the screen brightness from 0 to 1 (two decimals).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/getScreenBrightness"
Response:
{
"success": true,
"data": 0.6
}GET /api/setScreenBrightness — Set screen brightness
Sets the screen brightness. Pass brightness (or its alias value) from 0 to 1.
Modes: agent, hid
Parameters:
brightness(query, required, number): Brightness from 0 to 1. Alias: value.
Example:
curl "http://phone-ip:9800/api/setScreenBrightness?brightness=0.5"
Response:
{
"success": true
}GET /api/getVolume — Get media volume
Returns the system output volume from 0 to 1 (two decimals).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/getVolume"
Response:
{
"success": true,
"data": 0.5
}GET /api/setVolume — Set media volume
Sets the system output volume. Pass volume (or its alias value) from 0 to 1.
Modes: agent, hid
Parameters:
volume(query, required, number): Volume from 0 to 1. Alias: value.
Example:
curl "http://phone-ip:9800/api/setVolume?volume=0.3"
Response:
{
"success": true
}GET /api/getRunMode — Get current run mode
Returns the selected run mode (agent or hid) and whether each channel is currently usable. Also reachable as /api/control/getRunMode.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/getRunMode"
Response:
{
"success": true,
"data": {
"runMode": "agent",
"agentAvailable": true,
"isHidConnected": false
}
}GET /api/setRunMode — Switch run mode
Switches between Agent and HID mode. Switching to hid immediately closes the Agent automation session; switching to agent is refused with HTTP 409 when the Agent channel is not available. Also reachable as /api/control/setRunMode.
Modes: agent, hid
Parameters:
mode(query, required, string; one of agent, hid): Target run mode.
Example:
curl "http://phone-ip:9800/api/setRunMode?mode=hid"
Response:
{
"success": true,
"data": {
"runMode": "hid",
"agentAvailable": true,
"isHidConnected": true
}
}Scripts & Packages
Run JavaScript snippets, and upload, load, run and stop script packages.
POST /api/runScript — Run a JavaScript snippet
Runs JavaScript in the built-in engine and returns the value of the last expression (no return needed), e.g. appleOcr.recognize('screen'). Scripts are executed one at a time; after timeout seconds the call returns while the script may keep running.
Modes: agent, hid
Parameters:
timeout(query, number; default 15): Seconds to wait for the result before returning.
Request body (JSON):
{
"script": "let a = 1;\na + 1;"
}Example:
curl -X POST "http://phone-ip:9800/api/runScript" \
-H "Content-Type: application/json" \
-d '{"script": "let a = 1;\na + 1;"}'Response:
{
"success": true,
"resultType": "number",
"result": 2,
"data": {
"result": 2,
"logs": [],
"durationMs": 3
}
}GET /api/run — Run the current script package
Starts the entry script of the currently loaded package (see /api/load and /api/sync). If a script or code parameter is supplied, it instead behaves like /api/runScript.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/run"
Response:
{
"success": true,
"message": "运行成功"
}GET /api/runUI — Show the UI of the current package
Shows the configuration UI of the currently loaded package in the app (sets isShowUI=true). Fails if the package has no entry script.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/runUI"
Response:
{
"success": true,
"message": "UI运行成功"
}GET /api/stop — Stop the running script
Requests the running package script (or a running /api/runScript snippet) to stop. Returns success=false when nothing is running.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/stop"
Response:
{
"success": true,
"message": "停止成功"
}GET /api/load — Load a script package
Makes the package with the given appNo the current package; if it is not installed locally it is downloaded first. Refused while a script is running.
Modes: agent, hid
Parameters:
appNo(query, required, string): Package number / identifier.
Example:
curl "http://phone-ip:9800/api/load?appNo=demo"
Response:
{
"success": true,
"message": "加载成功",
"data": {
"softwareName": "demo",
"downloaded": false,
"appNo": "demo"
}
}POST /api/sync — Upload (sync) a script package
Uploads a zipped script project as the raw request body and makes it the current package. The zip must contain a file named appId at its root; its content becomes the package appNo.
Modes: agent, hid
Parameters:
projectName(query, string): Display name of the project (defaults to the appId).
Example:
curl -X POST "http://phone-ip:9800/api/sync" \
-H "Content-Type: application/json" \
-d '{}'Response:
{
"success": true,
"message": "同步成功"
}Agent Control
Touch, typing, keys, app control and UI-tree reading through the Agent channel (no hardware). Designed for Agent mode; in HID mode most /api/control/* calls are forwarded to the HID channel.
GET /api/source — Get the UI element tree (XML)
Returns the accessibility element tree of the foreground app as XML (XCUIElementType* elements with frame, label, value, etc.). Agent mode only. With meta=1 a JSON summary is returned instead of XML.
Modes: agent
Parameters:
mode(query, integer; default 1; one of 1, 2, 3): Capture mode, the same three modes as createNodeSelector({mode}) in scripts. 1 = one snapshot of the whole tree (22 attributes per node, depth 50, unlimited children); the default, fastest and most stable. 2 = stitched capture: 2 levels per request with 13 attributes per node, then every cut-off node is requested again and its subtree attached in place; for long lists and very deep trees, slower (one request per container). 3 = stitched capture with 1 level per request (13 attributes, at most 256 children per level). Modes 2 and 3 attach subtrees in place, so they do not return duplicate nodes.pid(query, integer): Process id of the app to read. Omit to read the foreground app.meta(query, integer; default 0; one of 0, 1): When 1, return JSON metadata (target, node count, size, elapsed time) instead of XML.max_depth(query, integer): Accepted for compatibility; ignored by the default capture engine.timeout(query, integer): Accepted for compatibility; ignored by the default capture engine.
Example:
curl "http://phone-ip:9800/api/source"
Response: text/xml
GET /api/activeAppInfo — Get the foreground app
Returns name, bundleId and pid of the app currently in the foreground, read from the root of the UI tree. Agent mode only (in HID mode use /api/hid/currentAppInfo).
Modes: agent
Example:
curl "http://phone-ip:9800/api/activeAppInfo"
Response:
{
"success": true,
"data": {
"name": "Settings",
"bundleId": "com.apple.Preferences",
"pid": 1234
}
}GET /api/control/click — Tap
Taps at a point (physical pixels). In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
x(query, required, number): X coordinate in physical screen pixels.y(query, required, number): Y coordinate in physical screen pixels.duration(query, integer; default 0): Press duration in milliseconds.jitter(query, boolean; default false): Add a small random offset to the touch point.
Example:
curl "http://phone-ip:9800/api/control/click?x=540&y=1200"
Response:
{
"success": true
}GET /api/control/doubleClick — Double tap
Double-taps at a point (physical pixels). In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
x(query, required, number): X coordinate in physical screen pixels.y(query, required, number): Y coordinate in physical screen pixels.duration(query, integer): Press duration of each tap in milliseconds.interval(query, integer): Pause between the two taps in milliseconds.jitter(query, boolean; default false): Add a small random offset.
Example:
curl "http://phone-ip:9800/api/control/doubleClick?x=540&y=1200"
Response:
{
"success": true
}GET /api/control/swipe — Swipe
Swipes from (startX,startY) to (endX,endY), in physical pixels. In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
startX(query, required, number): Start X (pixels).startY(query, required, number): Start Y (pixels).endX(query, required, number): End X (pixels).endY(query, required, number): End Y (pixels).duration(query, integer): Swipe duration in milliseconds.jitter(query, boolean; default false): Use a slightly irregular, human-like path.steps(query, integer): Number of intermediate points on the path.
Example:
curl "http://phone-ip:9800/api/control/swipe?startX=540&startY=1800&endX=540&endY=600"
Response:
{
"success": true
}GET /api/control/input — Type text
Types text into the focused input field. Requires the keyboard to be up. Supports any Unicode text; when the ketec keyboard is on screen the text is inserted through it. In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
text(query, required, string): Text to type. URL-encode it; a literal "+" must be sent as %2B because "+" decodes to a space.
Example:
curl "http://phone-ip:9800/api/control/input?text=你好 ketec"
Response:
{
"success": true,
"data": "你好 ketec",
"elapsedMs": 120
}GET /api/control/inputSimple — Type text key by key
Types text with key-by-key timing (about 15 characters per second), for fields that react to individual key events. Requires the keyboard to be up. In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
text(query, required, string): Text to type (URL-encoded; send "+" as %2B).
Example:
curl "http://phone-ip:9800/api/control/inputSimple?text=abc123"
Response:
{
"success": true,
"data": "abc123",
"elapsedMs": 420
}GET /api/control/backspace — Backspace
Deletes characters before the cursor. Requires the keyboard to be up. In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
count(query, integer; default 1): Number of characters to delete.
Example:
curl "http://phone-ip:9800/api/control/backspace"
Response:
{
"success": true
}GET /api/control/enter — Press Return
Presses the Return key. Requires the keyboard to be up. In HID mode this request is executed by the HID channel instead.
Modes: agent
Example:
curl "http://phone-ip:9800/api/control/enter"
Response:
{
"success": true
}GET /api/control/home — Go to the Home screen
Returns to the Home screen. Hardware buttons have no Agent-side implementation: the request is relayed to the HID device, so it only works while an ESP32-S3 HID device is connected; otherwise success is false.
Modes: agent
Example:
curl "http://phone-ip:9800/api/control/home"
Response:
{
"success": true,
"channel": "hid",
"button": "home"
}GET /api/control/recent — Open the app switcher
Opens the app switcher. Like /api/control/home, this needs a connected HID device.
Modes: agent
Example:
curl "http://phone-ip:9800/api/control/recent"
Response:
{
"success": true,
"channel": "hid",
"button": "recent"
}GET /api/control/pressButton — Press a hardware/media button
Presses a button through the HID device (needs a connected HID device, see /api/control/home). eject shows/hides the on-screen keyboard; power sends Ctrl+Cmd+Q (the iOS lock-screen shortcut); snapshot sends Cmd+Shift+3 (system screenshot).
Modes: agent
Parameters:
button(query, required, string; one of home, volumeup, volumedown, mute, playpause, next, prev, brightnessup, brightnessdown, eject, globe, recent, search, snapshot, power): Button name (case-sensitive). appswitch is accepted as an alias of recent.
Example:
curl "http://phone-ip:9800/api/control/pressButton?button=volumeup"
Response:
{
"success": true,
"channel": "hid",
"button": "volumeup"
}POST /api/control/sendKey — Send a key combination
Presses a key or key combination, e.g. ["COMMAND","a"]. Keys are single characters or names such as COMMAND, LEFT_SHIFT, LEFT_CTRL, LEFT_ALT, RETURN, ESC, BACKSPACE, TAB, SPACE, DELETE, HOME, END, PAGE_UP, PAGE_DOWN, UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW, F1–F12; numbers are taken as USB HID usage codes. A comma-separated keys query parameter is also accepted. In HID mode this request is executed by the HID channel instead.
Modes: agent
Request body (JSON):
{
"keys": [
"COMMAND",
"a"
]
}Example:
curl -X POST "http://phone-ip:9800/api/control/sendKey" \
-H "Content-Type: application/json" \
-d '{"keys": ["COMMAND", "a"]}'Response:
{
"success": true
}POST /api/control/w3cActions — Perform W3C pointer actions
Executes a W3C WebDriver actions payload: pointer sources (touch or mouse) with pointerMove, pointerDown, pointerUp and pause steps; several pointer sources make a multi-touch gesture. Coordinates are physical pixels and durations are milliseconds. Unsupported types are rejected with an explicit message. Agent mode only (not forwarded in HID mode).
Modes: agent
Request body (JSON):
{
"actions": [
{
"type": "pointer",
"id": "finger1",
"parameters": {
"pointerType": "touch"
},
"actions": [
{
"type": "pointerMove",
"duration": 0,
"x": 540,
"y": 1800
},
{
"type": "pointerDown",
"button": 0
},
{
"type": "pointerMove",
"duration": 300,
"x": 540,
"y": 600
},
{
"type": "pointerUp",
"button": 0
}
]
}
]
}Example:
curl -X POST "http://phone-ip:9800/api/control/w3cActions" \
-H "Content-Type: application/json" \
-d '{"actions": [{"type": "pointer", "id": "finger1", "parameters": {"pointerType": "touch"}, "actions": [{"type": "pointerMove", "duration": 0, "x": 540, "y": 1800}, {"type": "pointerDown", "button": 0}, {"type": "pointerMove", "duration": 300, "x": 540, "y": 600}, {"type": "pointerUp", "button": 0}]}]}'Response:
{
"success": true
}GET /api/control/startApp — Launch an app
Launches the app with the given bundle id. If the Agent call fails, ketec falls back to the system workspace API and marks the reply with deviation=true. In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
bundleId(query, required, string): Bundle identifier of the target app.
Example:
curl "http://phone-ip:9800/api/control/startApp?bundleId=com.apple.Preferences"
Response:
{
"success": true,
"via": "xct-ag",
"strict": false,
"bundleId": "com.apple.Preferences",
"action": "startApp"
}GET /api/control/activateApp — Bring an app to the foreground
Brings the app with the given bundle id to the foreground, launching it if needed. If the Agent call fails, ketec falls back to the system workspace API and marks the reply with deviation=true. In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
bundleId(query, required, string): Bundle identifier of the target app.
Example:
curl "http://phone-ip:9800/api/control/activateApp?bundleId=com.apple.Preferences"
Response:
{
"success": true,
"via": "xct-ag",
"strict": false,
"bundleId": "com.apple.Preferences",
"action": "activateApp"
}GET /api/control/stopApp — Terminate an app
Terminates the app with the given bundle id. If the Agent call fails, ketec falls back to the system workspace API and marks the reply with deviation=true. In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
bundleId(query, required, string): Bundle identifier of the target app.
Example:
curl "http://phone-ip:9800/api/control/stopApp?bundleId=com.apple.Preferences"
Response:
{
"success": true,
"via": "xct-ag",
"strict": false,
"bundleId": "com.apple.Preferences",
"action": "stopApp"
}GET /api/control/openURL — Open a URL
Opens a URL or URL scheme (e.g. https://..., prefs:...) with the system. In HID mode this request is executed by the HID channel instead.
Modes: agent
Parameters:
url(query, required, string): URL to open (URL-encoded).
Example:
curl "http://phone-ip:9800/api/control/openURL?url=https://example.com"
Response:
{
"success": true
}HID Control
Touch, typing and buttons through the ESP32-S3 USB HID device. Use in HID mode with the device plugged in. Coordinates are physical pixels.
GET /api/hid/click — Tap (HID)
Taps at a point through the ESP32-S3 HID device. Coordinates are physical screen pixels (1:1 with the screenshot), not logical points. The reply reports requested vs. sent coordinates and whether the point was out of range.
Modes: hid
Parameters:
x(query, required, number): X coordinate in physical screen pixels.y(query, required, number): Y coordinate in physical screen pixels.duration(query, integer): Press duration in milliseconds.mode(query, string; one of drag): drag = press, move a few pixels, release; helps with some system alerts and menu buttons.
Example:
curl "http://phone-ip:9800/api/hid/click?x=540&y=1200"
Response:
{
"success": true,
"data": {
"requested": {
"x": 540,
"y": 1200
},
"sent": {
"x": 540,
"y": 1200
},
"screenPx": {
"width": 1170,
"height": 2532
},
"outOfRange": false,
"mode": "absClick",
"pointerMode": "absolute",
"hint": "ok"
}
}GET /api/hid/doubleClick — Double tap (HID)
Double-taps through the HID device. Coordinates are physical screen pixels (1:1 with the screenshot), not logical points.
Modes: hid
Parameters:
x(query, required, number): X coordinate in physical screen pixels.y(query, required, number): Y coordinate in physical screen pixels.duration(query, integer; default 20): Press duration of each tap in milliseconds.interval(query, integer; default 100): Pause between taps in milliseconds.
Example:
curl "http://phone-ip:9800/api/hid/doubleClick?x=540&y=1200"
Response:
{
"success": true
}GET /api/hid/swipe — Swipe (HID)
Swipes through the HID device along a multi-point path. Coordinates are physical screen pixels (1:1 with the screenshot), not logical points.
Modes: hid
Parameters:
startX(query, required, number): Start X (pixels).startY(query, required, number): Start Y (pixels).endX(query, required, number): End X (pixels).endY(query, required, number): End Y (pixels).jitter(query, boolean; default false): Add random deviation to intermediate points.steps(query, integer; default 10): Number of path segments.duration(query, integer; default 0): Approximate total duration in milliseconds (0 = firmware default speed).
Example:
curl "http://phone-ip:9800/api/hid/swipe?startX=540&startY=1800&endX=540&endY=600"
Response:
{
"success": true
}GET /api/hid/move — Move the pointer (HID)
Moves the HID pointer to a point without pressing. Combine with mouseDown / mouseUp for custom drags. Coordinates are physical screen pixels (1:1 with the screenshot), not logical points.
Modes: hid
Parameters:
x(query, required, number): X coordinate in physical screen pixels.y(query, required, number): Y coordinate in physical screen pixels.
Example:
curl "http://phone-ip:9800/api/hid/move?x=540&y=1200"
Response:
{
"success": true
}GET /api/hid/mouseDown — Press the pointer (HID)
Presses at the current HID pointer position and keeps holding until /api/hid/mouseUp.
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/mouseDown"
Response:
{
"success": true
}GET /api/hid/mouseUp — Release the pointer (HID)
Releases the HID pointer.
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/mouseUp"
Response:
{
"success": true
}GET /api/hid/input — Type text (HID)
Types text in HID mode (requires the keyboard to be up). Order: ketec keyboard extension if it is on screen, otherwise clipboard + Cmd+V through the HID device. stage tells which path was used; success on stage 3-custom1 cannot be confirmed.
Modes: hid
Parameters:
text(query, required, string): Text to type (any Unicode; URL-encoded, send "+" as %2B). Also accepted as JSON body {"text": ...}.
Example:
curl "http://phone-ip:9800/api/hid/input?text=你好"
Response:
{
"success": true,
"data": true,
"stage": "2-clipboard"
}GET /api/hid/inputSimple — Type ASCII key by key (HID)
Types printable ASCII characters as individual key presses (requires the keyboard to be up). Non-ASCII text is rejected with 400; use /api/hid/input for Chinese and other text.
Modes: hid
Parameters:
text(query, required, string): ASCII text to type (URL-encoded; send "+" as %2B).
Example:
curl "http://phone-ip:9800/api/hid/inputSimple?text=abc123"
Response:
{
"success": true
}GET /api/hid/backspace — Backspace (HID)
Sends Backspace key presses through the HID device (keyboard must be up).
Modes: hid
Parameters:
count(query, integer; default 1): Number of presses.
Example:
curl "http://phone-ip:9800/api/hid/backspace"
Response:
{
"success": true
}GET /api/hid/enter — Press Return (HID)
Sends the Return key through the HID device (keyboard must be up).
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/enter"
Response:
{
"success": true
}GET /api/hid/home — Go to the Home screen (HID)
Sends the Home consumer key through the HID device.
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/home"
Response:
{
"success": true
}GET /api/hid/recent — Open the app switcher (HID)
Presses Home twice through the HID device to open the app switcher.
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/recent"
Response:
{
"success": true
}GET /api/hid/pressButton — Press a hardware/media button (HID)
Presses a button through the HID device. eject toggles the on-screen keyboard (optional state=show|hide) and returns extra detail in data; power sends Ctrl+Cmd+Q (the iOS lock-screen shortcut); snapshot sends Cmd+Shift+3 (system screenshot). Unknown names return success=false.
Modes: hid
Parameters:
button(query, required, string; one of home, volumeup, volumedown, mute, playpause, next, prev, brightnessup, brightnessdown, eject, globe, recent, search, snapshot, power): Button name (case-sensitive).state(query, string; one of show, hide): Only for button=eject: force show or hide instead of toggling.
Example:
curl "http://phone-ip:9800/api/hid/pressButton?button=home"
Response:
{
"success": true
}POST /api/hid/sendKey — Send a key combination (HID)
Presses a key combination through the HID device, e.g. ["COMMAND","v"]. Keys are single characters or names: COMMAND, ENTER/RETURN, ESC, BACKSPACE, TAB, SPACE, CAPS_LOCK, INSERT, HOME, END, PAGE_UP, PAGE_DOWN, DELETE, UP_ARROW, DOWN_ARROW, LEFT_ARROW, RIGHT_ARROW; numbers are passed to the firmware as key codes. A comma-separated keys query parameter is also accepted.
Modes: hid
Request body (JSON):
{
"keys": [
"COMMAND",
"v"
]
}Example:
curl -X POST "http://phone-ip:9800/api/hid/sendKey" \
-H "Content-Type: application/json" \
-d '{"keys": ["COMMAND", "v"]}'Response:
{
"success": true
}GET /api/hid/openApp — Open an app
Launches an app by display name or bundle id. Does not need the HID hardware.
Modes: hid
Parameters:
name(query, required, string): App display name or bundle id (alias: bundleId).
Example:
curl "http://phone-ip:9800/api/hid/openApp?name=Settings"
Response:
{
"success": true,
"data": {
"bundleId": "com.apple.Preferences"
}
}GET /api/hid/closeApp — Close an app
Terminates an app by display name or bundle id. If the system refuses, and a HID device is connected, ketec closes it with gestures (open app, Home, app switcher, swipe the card up), reported as via=hid-gesture.
Modes: hid
Parameters:
name(query, required, string): App display name or bundle id (alias: bundleId).
Example:
curl "http://phone-ip:9800/api/hid/closeApp?name=Settings"
Response:
{
"success": true,
"data": {
"bundleId": "com.apple.Preferences",
"via": "terminate"
}
}GET /api/hid/openURL — Open a URL (HID mode)
Opens a URL. Uses the ketec helper Shortcut when available (works while ketec is in the background, accepts addresses without a scheme), otherwise opens it locally, adding https:// when no scheme is given.
Modes: hid
Parameters:
url(query, required, string): URL to open (URL-encoded).
Example:
curl "http://phone-ip:9800/api/hid/openURL?url=https://example.com"
Response:
{
"success": true,
"data": {
"url": "https://example.com"
}
}GET /api/hid/currentAppInfo — Get the foreground app (HID mode)
Returns bundleId and name of the foreground app without using the Agent channel. Fails with message when it cannot be determined.
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/currentAppInfo"
Response:
{
"success": true,
"data": {
"bundleId": "com.apple.Preferences",
"name": "Settings"
}
}GET /api/hid/deviceInfo — Get HID device info
Returns whether the ESP32-S3 HID device is connected, plus its model, firmware version and MAC address as last reported. Also asks the device to refresh this information.
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/deviceInfo"
Response:
{
"success": true,
"data": {
"connected": true,
"model": "<model>",
"version": "<firmware-version>",
"mac": "<mac>",
"lastResponse": "",
"transmitted": 128
}
}GET /api/hid/restartDevice — Restart the HID device
Sends a restart command to the ESP32-S3 firmware (it does not restart the phone). The device re-enumerates over USB, so HID control is unavailable for a few seconds until it reconnects.
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/restartDevice"
Response:
{
"success": true
}GET /api/hid/shortcutScreenshot — Screenshot via Shortcut (PNG)
Captures the screen through the ketec helper Shortcut, triggered by the HID device; requires the helper Shortcut to be installed and a connected HID device. Can take several seconds (timeout 20 s). Returns PNG.
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/shortcutScreenshot"
Response: image/png
GET /api/hid/shortcutScreenshotBase64 — Screenshot via Shortcut (Base64)
Captures the screen through the ketec helper Shortcut, triggered by the HID device; requires the helper Shortcut to be installed and a connected HID device. Can take several seconds (timeout 20 s). Returns the PNG Base64-encoded in data.
Modes: hid
Example:
curl "http://phone-ip:9800/api/hid/shortcutScreenshotBase64"
Response:
{
"success": true,
"data": "iVBORw0KGgoAAAANSUhEUgAA..."
}Keyboard
Text input through the ketec keyboard extension (/api/ime/*). Most calls need the ketec keyboard enabled and a keyboard on screen.
GET /api/ime/isOk — Check whether the ketec keyboard is ready
success is true when the ketec keyboard is installed and currently visible. data explains the details (current input mode, whether it is ketec's keyboard, time since the extension last checked in).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/ime/isOk"
Response:
{
"success": true,
"superset": true,
"data": {
"keyboardInstalled": true,
"keyboardVisible": true,
"currentInputModeIdentifier": "<input-mode-id>",
"targetInputModeIdentifier": "<input-mode-id>",
"isOurKeyboard": true,
"lastPollAgoMs": 120,
"neverPolled": false
}
}GET /api/ime/input — Insert text via the ketec keyboard
Requires the ketec keyboard to be added in iOS Settings (with Full Access) and a keyboard to be on screen. If another keyboard is showing, ketec switches to its own keyboard first, then inserts the text in one piece (any Unicode, including emoji). Fails with a reason when no keyboard is up.
Modes: agent, hid
Parameters:
text(query, required, string): Text to insert (URL-encoded; send "+" as %2B). Also accepted as JSON body {"text": ...}.
Example:
curl "http://phone-ip:9800/api/ime/input?text=你好👋"
Response:
{
"success": true,
"via": "unix-socket",
"data": "你好👋",
"readbackLen": 4,
"extKeyboardVisible": true
}GET /api/ime/paste — Paste via the ketec keyboard
Requires the ketec keyboard to be added in iOS Settings (with Full Access) and a keyboard to be on screen. Without text the keyboard extension pastes the current clipboard content; with text that text is inserted instead.
Modes: agent, hid
Parameters:
text(query, string): Optional text to insert instead of the clipboard content.
Example:
curl "http://phone-ip:9800/api/ime/paste"
Response:
{
"success": true,
"via": "unix-socket",
"readbackLen": 12
}GET /api/ime/getText — Read the text before the cursor
Requires the ketec keyboard to be added in iOS Settings (with Full Access) and a keyboard to be on screen. Returns the text before the cursor in the focused field as seen by the keyboard. iOS may truncate long content; returns an empty string when there is no input session.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/ime/getText"
Response:
{
"success": true,
"via": "unix-socket",
"data": "hello",
"readbackLen": 5
}GET /api/ime/clearText — Clear the focused field
Requires the ketec keyboard to be added in iOS Settings (with Full Access) and a keyboard to be on screen. Deletes the text before the cursor until the field is empty (long text is deleted in rounds).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/ime/clearText"
Response:
{
"success": true,
"via": "unix-socket",
"readbackLen": 0,
"deletedCount": 5,
"superset": true
}GET /api/ime/pressDel — Press Delete
Requires the ketec keyboard to be added in iOS Settings (with Full Access) and a keyboard to be on screen. Deletes characters before the cursor.
Modes: agent, hid
Parameters:
count(query, integer; default 1): Number of characters to delete.
Example:
curl "http://phone-ip:9800/api/ime/pressDel"
Response:
{
"success": true,
"via": "unix-socket",
"readbackLen": 4,
"deletedCount": 1,
"superset": true
}GET /api/ime/pressEnter — Press Return
Requires the ketec keyboard to be added in iOS Settings (with Full Access) and a keyboard to be on screen. Inserts a Return (new line / submit, depending on the field).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/ime/pressEnter"
Response:
{
"success": true,
"via": "unix-socket"
}GET /api/ime/dismiss — Hide the keyboard
Requires the ketec keyboard to be added in iOS Settings (with Full Access) and a keyboard to be on screen. Dismisses the keyboard. If the extension cannot do it and a HID device is connected, ketec taps outside the keyboard; otherwise it fails with reason keyboard_still_visible.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/ime/dismiss"
Response:
{
"success": true,
"via": "unix-socket"
}GET /api/ime/getClipboard — Read the clipboard via the keyboard
Requires the ketec keyboard to be added in iOS Settings (with Full Access) and a keyboard to be on screen. Reads the clipboard through the keyboard extension, which avoids the iOS paste-permission prompt. Returns an empty string when the keyboard is not available.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/ime/getClipboard"
Response:
{
"success": true,
"data": "copied text",
"length": 11,
"chars": 11,
"source": "http-fallback"
}GET /api/ime/setClipboard — Write the clipboard
Writes text to the system clipboard (does not need the keyboard). verified is "true" when it could be read back, "unknown" when reading back was blocked by iOS.
Modes: agent, hid
Parameters:
text(query, required, string): Text to write, kept verbatim (URL-encoded; send "+" as %2B). Also accepted as JSON body {"text": ...}.
Example:
curl "http://phone-ip:9800/api/ime/setClipboard?text=hello"
Response:
{
"success": true,
"data": {
"via": "uipasteboard",
"written": true,
"verified": "true",
"len": 5,
"encoding": 5,
"chars": 5
}
}Clipboard & Config
System clipboard access from the main app, and the app key/value configuration.
GET /api/getClipboard — Read the clipboard
Reads the system clipboard from the main app. iOS may block this read (paste permission); then needsUserPermission=true is returned and /api/ime/getClipboard is the better choice.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/getClipboard"
Response:
{
"success": true,
"data": "copied text",
"meta": {
"data": "copied text",
"source": "system",
"changeCount": 42
}
}GET /api/setClipboard — Write the clipboard
Writes text to the system clipboard. The text is kept verbatim (leading/trailing spaces preserved).
Modes: agent, hid
Parameters:
text(query, required, string): Text to write (alias: value; URL-encoded, send "+" as %2B). Also accepted as JSON body {"text": ...}.
Example:
curl "http://phone-ip:9800/api/setClipboard?text=hello"
Response:
{
"success": true
}GET /api/getAllConfig — Get all config values
Returns the app key/value configuration as an object in data and the same content as a JSON string in json. Values are strings.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/getAllConfig"
Response:
{
"success": true,
"data": {
"runMode": "agent"
},
"json": "{\"runMode\":\"agent\"}"
}GET /api/setConfig — Set one config value
Sets one configuration value. key and value are read from the query string only (a JSON body is not read), so POST works too as long as the values are in the query. Setting key=runMode also switches the run mode.
Modes: agent, hid
Parameters:
key(query, required, string): Config key.value(query, string): Config value (empty string if omitted).
Example:
curl "http://phone-ip:9800/api/setConfig?key=runMode"
Response:
{
"success": true
}POST /api/setAllConfig — Set several config values
Merges the key/value pairs of the JSON body into the configuration. Non-string values are stored as their string form; existing keys not in the body are kept.
Modes: agent, hid
Request body (JSON):
{
"theme": "dark",
"retry": "3"
}Example:
curl -X POST "http://phone-ip:9800/api/setAllConfig" \
-H "Content-Type: application/json" \
-d '{"theme": "dark", "retry": "3"}'Response:
{
"success": true
}Files
Manage files in the app sandbox (Documents or temporary directory).
GET /api/file/list — List files
Recursively lists files and folders under the sandbox root (or under path). Up to 5000 entries, sorted by path; folders have size 0. Paths are relative to the chosen sandbox root; ".." is rejected.
Modes: agent, hid
Parameters:
dirType(query, string; default "documents"; one of documents, temp): Sandbox root: the App's Documents directory or its temporary directory.path(query, string): Optional sub-folder to list.
Example:
curl "http://phone-ip:9800/api/file/list"
Response:
{
"success": true,
"data": [
{
"name": "records",
"path": "records",
"isDirectory": true,
"size": 0,
"modified": 1764460800
},
{
"name": "a.txt",
"path": "a.txt",
"isDirectory": false,
"size": 12,
"modified": 1764460800
}
]
}GET /api/file/exists — Check whether a path exists
Reports whether the path exists and whether it is a folder. Paths are relative to the chosen sandbox root; ".." is rejected.
Modes: agent, hid
Parameters:
dirType(query, string; default "documents"; one of documents, temp): Sandbox root: the App's Documents directory or its temporary directory.path(query, required, string): Relative path.
Example:
curl "http://phone-ip:9800/api/file/exists?path=a.txt"
Response:
{
"success": true,
"data": {
"exists": true,
"isDirectory": false
}
}POST /api/file/upload — Upload a file
Writes the raw request body to path (parent folders are created, existing files are overwritten). Maximum 200 MB. Paths are relative to the chosen sandbox root; ".." is rejected.
Modes: agent, hid
Parameters:
dirType(query, string; default "documents"; one of documents, temp): Sandbox root: the App's Documents directory or its temporary directory.path(query, required, string): Destination relative path including file name.
Example:
curl -X POST "http://phone-ip:9800/api/file/upload?path=scripts/main.js" \
-H "Content-Type: application/json" \
-d '{}'Response:
{
"success": true,
"data": {
"path": "/scripts/main.js",
"bytes": 1024
}
}GET /api/file/download — Download a file
Returns the file content as application/octet-stream. Screen recordings are stored under records/ in documents. Paths are relative to the chosen sandbox root; ".." is rejected.
Modes: agent, hid
Parameters:
dirType(query, string; default "documents"; one of documents, temp): Sandbox root: the App's Documents directory or its temporary directory.path(query, required, string): Relative path of the file.
Example:
curl "http://phone-ip:9800/api/file/download?path=a.txt"
Response: application/octet-stream
GET /api/file/delete — Delete a file
Deletes the file (or folder) at path. Paths are relative to the chosen sandbox root; ".." is rejected.
Modes: agent, hid
Parameters:
dirType(query, string; default "documents"; one of documents, temp): Sandbox root: the App's Documents directory or its temporary directory.path(query, required, string): Relative path.
Example:
curl "http://phone-ip:9800/api/file/delete?path=a.txt"
Response:
{
"success": true
}GET /api/file/deleteDir — Delete a folder
Deletes the folder at path with all its content; fails if the path is not a folder. Paths are relative to the chosen sandbox root; ".." is rejected.
Modes: agent, hid
Parameters:
dirType(query, string; default "documents"; one of documents, temp): Sandbox root: the App's Documents directory or its temporary directory.path(query, required, string): Relative folder path.
Example:
curl "http://phone-ip:9800/api/file/deleteDir?path=tmp"
Response:
{
"success": true
}Media
Save images/videos to the Photos library and bulk-delete media.
POST /api/media/saveImageToAlbum — Save an image to the Photos album
Saves an image to the system Photos library. Accepts raw bytes, multipart/form-data (several files), JSON with Base64 data, or a url to download. The type is detected from the file header. Max 200 MB. The first call asks the user for photo-library permission on the phone.
Modes: agent, hid
Parameters:
filename(query, string): File name; its extension helps detect the format.url(query, string): http/https link to download and save instead of sending a body.
Request body (JSON):
{
"data": "iVBORw0KGgo...",
"filename": "a.png"
}Example:
curl -X POST "http://phone-ip:9800/api/media/saveImageToAlbum" \
-H "Content-Type: application/json" \
-d '{"data": "iVBORw0KGgo...", "filename": "a.png"}'Response:
{
"success": true,
"data": {
"filename": "photo.jpg",
"bytes": 5364,
"kind": "image",
"success": true,
"localIdentifier": "<asset-id>"
}
}POST /api/media/saveVideoToAlbumPath — Save a video to the Photos album
Saves a video to the system Photos library (H.264 .mp4 / .mov recommended). Accepts raw bytes, multipart/form-data (several files), JSON with Base64 data, or a url to download. The type is detected from the file header. Max 200 MB. The first call asks the user for photo-library permission on the phone.
Modes: agent, hid
Parameters:
filename(query, string): File name; its extension helps detect the format.url(query, string): http/https link to download and save instead of sending a body.
Request body (JSON):
{
"data": "iVBORw0KGgo...",
"filename": "a.png"
}Example:
curl -X POST "http://phone-ip:9800/api/media/saveVideoToAlbumPath" \
-H "Content-Type: application/json" \
-d '{"data": "iVBORw0KGgo...", "filename": "a.png"}'Response:
{
"success": true,
"data": {
"filename": "photo.jpg",
"bytes": 5364,
"kind": "image",
"success": true,
"localIdentifier": "<asset-id>"
}
}POST /api/media/save — Save images or videos to the album (auto-detect)
Unified upload: each file is saved as image or video according to its content. Accepts raw bytes, multipart/form-data (several files), JSON with Base64 data, or a url to download. The type is detected from the file header. Max 200 MB. The first call asks the user for photo-library permission on the phone. Also reachable as /api/media/upload.
Modes: agent, hid
Parameters:
filename(query, string): File name; its extension helps detect the format.url(query, string): http/https link to download and save instead of sending a body.
Request body (JSON):
{
"data": "iVBORw0KGgo...",
"filename": "a.png"
}Example:
curl -X POST "http://phone-ip:9800/api/media/save" \
-H "Content-Type: application/json" \
-d '{"data": "iVBORw0KGgo...", "filename": "a.png"}'Response:
{
"success": true,
"data": {
"filename": "photo.jpg",
"bytes": 5364,
"kind": "image",
"success": true,
"localIdentifier": "<asset-id>"
}
}GET /api/media/deleteAllPhotos — Delete all photos
Submits deletion of all photos (including screenshots) in the Photos library and returns immediately. iOS then shows a confirmation dialog; items are only deleted after the user confirms (deleted items go to Recently Deleted).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/media/deleteAllPhotos"
Response:
{
"success": true,
"data": {
"submitted": 12,
"kind": "照片",
"note": "已提交,系统会弹「允许删除」确认框,用户确认后才真正删除"
}
}GET /api/media/deleteAllVideos — Delete all videos
Submits deletion of all videos in the Photos library and returns immediately. iOS then shows a confirmation dialog; items are only deleted after the user confirms (deleted items go to Recently Deleted).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/media/deleteAllVideos"
Response:
{
"success": true,
"data": {
"submitted": 12,
"kind": "视频",
"note": "已提交,系统会弹「允许删除」确认框,用户确认后才真正删除"
}
}GET /api/media/deleteAllScreenshots — Delete all screenshots
Submits deletion of all screenshots in the Photos library and returns immediately. iOS then shows a confirmation dialog; items are only deleted after the user confirms (deleted items go to Recently Deleted).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/media/deleteAllScreenshots"
Response:
{
"success": true,
"data": {
"submitted": 12,
"kind": "截图",
"note": "已提交,系统会弹「允许删除」确认框,用户确认后才真正删除"
}
}Logs
Read and download the app logs.
GET /logger/files — List log files
Returns the app log files, newest first. The response body is a JSON array (no success wrapper).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/logger/files"
Response:
[
{
"filePath": "<app-sandbox>/Documents/logs/ketec.log",
"fileName": "ketec.log",
"modificationDate": "2026-11-30T08:00:00Z",
"fileSize": "120 KB"
}
]GET /logger/download — Download a log file
Returns the content of a log file as application/octet-stream. Without fileName the latest file (by name) is returned.
Modes: agent, hid
Parameters:
fileName(query, string): File name from /logger/files.
Example:
curl "http://phone-ip:9800/logger/download"
Response: application/octet-stream
GET /logger/current/lines — Get the latest log lines
Returns the last count non-empty lines of the current log. hasMore=true means older lines exist. The body has no success field.
Modes: agent, hid
Parameters:
count(query, integer; default 200): Number of lines to return.
Example:
curl "http://phone-ip:9800/logger/current/lines"
Response:
{
"lines": [
"[12:00:01] script started",
"[12:00:02] click 540,1200"
],
"hasMore": true
}Screen Mirror
Live screen streaming (MJPEG, H.264 FLV) and screen recording. Streaming needs the ketec screen broadcast to be running.
GET /mirror/image — Live screen stream (MJPEG)
Requires the ketec screen broadcast to be running (iOS requires the user to start it once from the system broadcast picker / Control Center). Streams JPEG frames as multipart/x-mixed-replace (boundary kcframe) until the client disconnects; usable directly in an <img> tag. Also reachable as /api/mirror/image and /api/mirror/mjpeg.
Modes: agent, hid
Parameters:
scalingFactor(query, number; default 1): Output size = device pixels × factor. Divide stream coordinates by this factor before sending clicks.
Example:
curl "http://phone-ip:9800/mirror/image"
Response: multipart/x-mixed-replace; boundary=kcframe
GET /mirror/flv — Live screen stream (H.264 HTTP-FLV)
Requires the ketec screen broadcast to be running (iOS requires the user to start it once from the system broadcast picker / Control Center). Streams H.264 video in an FLV container (video/x-flv) until the client disconnects; play it with an FLV player such as flv.js or ffplay. Also reachable as /api/mirror/flv.
Modes: agent, hid
Parameters:
fps(query, integer; default 10): Target frame rate.scalingFactor(query, number; default 1): Output size = device pixels × factor.bitrate(query, number; default 4): Target bitrate in Mbit/s.quality(query, number): Accepted for compatibility; has no visible effect (use scalingFactor).
Example:
curl "http://phone-ip:9800/mirror/flv"
Response: video/x-flv
GET /api/hid/openRecordScreen — Start screen recording
Starts recording to an MP4 file. If the screen broadcast is running, the whole screen is recorded; otherwise only ketec's own window. Files are saved under records/ in the documents sandbox (download with /api/file/download). Works in both modes; also reachable as /api/control/startRecordScreen.
Modes: agent, hid
Parameters:
fps(query, integer; default 10): Recording frame rate (1–30).source(query, string; one of broadcast, internal): Frame source. Default: broadcast when the screen broadcast is connected, otherwise internal (ketec window).
Example:
curl "http://phone-ip:9800/api/hid/openRecordScreen"
Response:
{
"success": true,
"data": {
"isRecording": true,
"fps": 10,
"frames": 0,
"duration": 0,
"path": "rec-20261130-120000.mp4",
"captureSource": "broadcast",
"frameSource": "broadcast",
"canCaptureFullScreen": true,
"broadcastSupported": true,
"lastBroadcastEvent": "started",
"lastBroadcastAt": 1764504000
}
}GET /api/hid/closeRecordScreen — Stop screen recording
Stops the current recording; the file is finalized in the background (saving=true). Returns success=false when nothing is being recorded. Also reachable as /api/control/stopRecordScreen.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/hid/closeRecordScreen"
Response:
{
"success": true,
"data": {
"name": "rec-20261130-120000.mp4",
"saving": true
}
}GET /api/hid/isRecording — Is the screen being recorded or broadcast
Returns true while ketec is recording or while the screen broadcast is running (same meaning as isRecording in /api/status).
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/hid/isRecording"
Response:
{
"success": true,
"data": false
}Account & License
Sign a phone in or out from a computer (TokenKey / account key, or username + password) and read its license status. These endpoints answer even when the device is not licensed. The license itself is checked by the App against the cloud license service; there is no cloud API that signs a device in remotely, so call these on each phone over the LAN.
GET /api/license — Get the device license status
Returns the license state of this phone: whether it is licensed (valid / isLogin), the reason, the account name when signed in with an account, the first 8 characters of the key in use, the device limit, online count and expiry of the license. Always answered, even when the device is not licensed. After /api/login the license is verified in the background; poll this endpoint until reason is no longer checking.
Modes: agent, hid
Example:
curl "http://phone-ip:9800/api/license"
Response:
{
"success": true,
"data": {
"enforced": true,
"valid": true,
"reason": "ok",
"message": "已授权",
"builtIn": false,
"hasKey": true,
"account": "",
"isLogin": true,
"key": "4F0DCB53…",
"deviceId": "<device-id>",
"expiresAt": 1827851075,
"maxDevices": 1500,
"online": 12,
"lastOK": 1796000100,
"lastCheck": 1796000100,
"server": "https://api.ketec.top"
}
}POST /api/login — Sign this device in (TokenKey or username + password)
Signs the phone in so that it uses the license of an account. Send either a key (account key or TokenKey; aliases token / tokenKey) or username + password; when username is present the account sign-in is used. A key is saved at once and verified in the background (data.reason = checking). An account sign-in waits up to 20 seconds for the license service, then saves the account's key. Any previous key or account on the phone is replaced and its online seat released. Fields can be sent as a JSON body or as query parameters. This endpoint works before the device is licensed. Fails on builds with a built-in license key.
Modes: agent, hid
Request body (JSON):
{
"tokenKey": "4F0DCB53-478C-456A-AFA9-E682F56FE73A"
}Example:
curl -X POST "http://phone-ip:9800/api/login" \
-H "Content-Type: application/json" \
-d '{"tokenKey": "4F0DCB53-478C-456A-AFA9-E682F56FE73A"}'Response:
{
"success": true,
"data": {
"enforced": true,
"valid": false,
"reason": "checking",
"message": "正在验证授权…",
"builtIn": false,
"hasKey": true,
"account": "",
"isLogin": false,
"key": "4F0DCB53…",
"deviceId": "<device-id>",
"expiresAt": 0,
"maxDevices": 0,
"online": 0,
"lastOK": 0,
"lastCheck": 1796000000,
"server": "https://api.ketec.top"
}
}POST /api/license/activate — Set the license key (TokenKey or account key)
Same as /api/login with a key: saves the key and verifies it in the background. Poll /api/license for the result (reason unknown_key = the key does not exist, token_revoked = the TokenKey was revoked).
Modes: agent, hid
Request body (JSON):
{
"key": "4F0DCB53-478C-456A-AFA9-E682F56FE73A"
}Example:
curl -X POST "http://phone-ip:9800/api/license/activate" \
-H "Content-Type: application/json" \
-d '{"key": "4F0DCB53-478C-456A-AFA9-E682F56FE73A"}'Response:
{
"success": true,
"data": {
"enforced": true,
"valid": false,
"reason": "checking",
"message": "正在验证授权…",
"builtIn": false,
"hasKey": true,
"account": "",
"isLogin": false,
"key": "4F0DCB53…",
"deviceId": "<device-id>",
"expiresAt": 0,
"maxDevices": 0,
"online": 0,
"lastOK": 0,
"lastCheck": 1796000000,
"server": "https://api.ketec.top"
}
}POST /api/register — Register an account and sign this device in
Creates a new account on the license service and signs the phone in with it (waits up to 20 seconds). A new account has no device license until one is bought, so data.reason becomes expired after verification. Username: 3–32 characters, starting with a letter or digit, letters, digits and _ . @ -; password: 6–64 characters.
Modes: agent, hid
Request body (JSON):
{
"username": "studio-a",
"password": "••••••••"
}Example:
curl -X POST "http://phone-ip:9800/api/register" \
-H "Content-Type: application/json" \
-d '{"username": "studio-a", "password": "••••••••"}'Response:
{
"success": true,
"data": {
"enforced": true,
"valid": false,
"reason": "checking",
"message": "正在验证授权…",
"builtIn": false,
"hasKey": true,
"account": "studio-a",
"isLogin": false,
"key": "4F0DCB53…",
"deviceId": "<device-id>",
"expiresAt": 0,
"maxDevices": 0,
"online": 0,
"lastOK": 0,
"lastCheck": 1796000000,
"server": "https://api.ketec.top"
}
}POST /api/logout — Sign this device out
Removes the key / account from the phone and releases its online seat on the license service. Afterwards most endpoints return the license error until the device signs in again. Alias: /api/license/logout.
Modes: agent, hid
Example:
curl -X POST "http://phone-ip:9800/api/logout" \
-H "Content-Type: application/json" \
-d '{}'Response:
{
"success": true,
"data": {
"enforced": true,
"valid": false,
"reason": "no_key",
"message": "未登录:请登录账号或输入授权码",
"builtIn": false,
"hasKey": false,
"account": "",
"isLogin": false,
"key": "",
"deviceId": "<device-id>",
"expiresAt": 0,
"maxDevices": 0,
"online": 0,
"lastOK": 0,
"lastCheck": 1796000000,
"server": "https://api.ketec.top"
}
}License Service
The cloud license service the App talks to (api.ketec.top). The App sends this heartbeat by itself every 60 seconds; it is documented here for reference only — you normally do not call it.
POST /v1/heartbeat — License heartbeat (reference)
Sent by the App every 60 seconds with its license key (an account key or a TokenKey) and device ID. The reply is a signed envelope: payload is a JSON string and sig is an Ed25519 signature over that exact string, verified with the public key built into the App. The App also checks that payload.key, payload.deviceId and payload.nonce equal what it sent (key echoes the TokenKey when one was used). ok: false comes with a machine-readable reason: bad_request, unknown_key, token_revoked, disabled, expired, kicked or device_limit.
Modes: agent, hid
Request body (JSON):
{
"key": "3F2A9C1E-7B4D-4E8A-9C21-5D6E7F809A1B",
"deviceId": "<device-id>",
"nonce": "6F1D2C3B-…",
"model": "iPhone13,2",
"ios": "26.5",
"appVersion": "330v240",
"name": "iPhone"
}Example:
curl -X POST "https://api.ketec.top/v1/heartbeat" \
-H "Content-Type: application/json" \
-d '{"key": "3F2A9C1E-7B4D-4E8A-9C21-5D6E7F809A1B", "deviceId": "<device-id>", "nonce": "6F1D2C3B-…", "model": "iPhone13,2", "ios": "26.5", "appVersion": "330v240", "name": "iPhone"}'Response:
{
"payload": "{\"key\":\"3F2A9C1E-7B4D-4E8A-9C21-5D6E7F809A1B\",\"deviceId\":\"<device-id>\",\"nonce\":\"6F1D2C3B-…\",\"serverTime\":1796300000,\"heartbeat\":60,\"ok\":true,\"reason\":\"ok\",\"message\":\"已授权\",\"maxDevices\":10,\"expiresAt\":1827843558,\"online\":3,\"customer\":\"studio-a\"}",
"sig": "<base64 Ed25519 签名>"
}