Agent
touches go through the system automation service. Node selectors, the UI tree, multi-finger gestures and W3C Actions are available. Requires a one-time activation from a computer over USB with ketec Activator (see Download).
Documentation
Start with the quick start, then browse the script modules and the HTTP API. Complete references are linked at the end of each section.
$ curl http://<iphone-ip>:9800/api/status # app and iOS version, device model, run mode, recording state $ curl "http://<iphone-ip>:9800/api/control/click?x=540&y=1200" # tapped at 540, 1200 $ curl -o screen.jpg http://<iphone-ip>:9800/api/screenshot # full-resolution JPEG saved
Five steps from a fresh install to your first automated tap.
Join through TestFlight on an iPhone with iOS 15 or later, then open ketec once so it can start its local service.
In Settings, pick Agent or HID. The Status tab shows whether the channel is ready.
Create scripts/main.js, scripts/main.lua or scripts/main.py. The examples below do the same thing in each language.
Install the package from the Packages tab, or post a JavaScript snippet to the HTTP API.
Register a stop callback. It receives success, error or stopped, so you can save state before the run ends.
// scripts/main.js
setStopCallback((status) => logi("finished: " + status));
logi("Hello from ketec on iOS " + device.getOSVersion());
system.startApp("com.apple.Preferences");
sleep(1500);
// Find "General" with on-device OCR and tap it
const hits = paddleOcr.findTextAbs("screen", ["General"]);
if (hits.length > 0) {
action.click(hits[0].centerX, hits[0].centerY);
}-- scripts/main.lua
SetStopCallback(function(status) logi("finished: " .. status) end)
logi("Hello from ketec on iOS " .. device.getOSVersion())
system.startApp("com.apple.Preferences")
sleep(1500)
-- Find "General" with on-device OCR and tap it
local hits = paddleOcr.findTextAbs("screen", {"General"})
if #hits > 0 then
action.click(hits[1].centerX, hits[1].centerY)
end# scripts/main.py
import time
from ketec import g, device, system, paddleocr, action
g.setStopCallback(lambda status: print("finished:", status))
print("Hello from ketec on iOS", device.getOSVersion())
system.startApp("com.apple.Preferences")
time.sleep(1.5)
# Find "General" with on-device OCR and tap it
hits = paddleocr.findTextAbs("screen", ["General"])
if hits:
action.click(hits[0].centerX, hits[0].centerY)Run a one-off snippet over the network (JavaScript only):
curl -X POST http://<iphone-ip>:9800/api/runScript \
-H "Content-Type: application/json" \
-d '{"script":"action.click(540, 1200); device.getOSVersion()"}'Both modes run the same scripts. They differ in how input reaches the system and what is available.
touches go through the system automation service. Node selectors, the UI tree, multi-finger gestures and W3C Actions are available. Requires a one-time activation from a computer over USB with ketec Activator (see Download).
an ESP32-S3 accessory on USB sends real mouse and keyboard input. Use the hid module or the /api/hid endpoints. The UI tree is not used in this mode; find targets with images and OCR. Two pointer modes cover older and newer iOS versions.
A package is a folder with an entry script plus any resources it needs. ketec picks the engine from the entry file.
scripts/main.js · scripts/main.lua · scripts/main.py | Entry script: JavaScript, Lua or Python |
file.readResFile() · image.readImage() | Images, models, fonts and other files |
ui.show() | Optional web settings page for the UI tab |
Settings saved with the config module are kept separately from the app’s own settings, persist between runs and keep their types: store 5 and you read back 5.
Module names and arguments are identical across languages. Only the syntax changes.
Modules are globals: action.click(x, y). Logging with logi / logd / logw / loge or console. Timers with setTimeout and setInterval.
Modules are global tables; objects use colon calls: sel:getOneNodeInfo(3000). Globals such as sleep, logi and SetStopCallback.
Import what you need: from ketec import action, image, g. Results support both r.name and r["name"]. Global helpers live in g.
A map of the modules available to scripts, grouped by what they do. Function names are the same in all three languages.
Nothing matches your search.
globalPython: g
Sleep, timing, logging, stop and exception callbacks, touch mode and CPU throttling.
sleeptimeexitlogilogwlogesetStopCallbacksetExceptionCallbackrestartScripttakeMeToFrontsetAgentTouchMode
action
Taps, swipes, curves, text input, buttons, key combos and multi-finger builders.
clickdoubleClickclickRandomswipeswipeCurvepressAndSwipeinputinputSimplebackspaceenterhomeScreenpressButtonsendKeyw3cActionscreateBuildersetJitterValue
node
Find controls in the UI tree and act on them. Agent mode.
createNodeSelectorlabellabelMatchtitleidentifiertypevaluexpathgetOneNodeInfogetNodeInfoclickCenterscrollToVisibleparentchildreleaseNode
image
Capture the screen, find images and colors, crop, rotate, binarize and scan codes.
captureScreenreadImagefindImagefindImageExfindColorfindMultiColorcountColorcmpColorpixelcliprotateImagebinaryzationscanCodesaveTorelease
device
Battery, storage, screen metrics, brightness, volume, orientation and identifiers.
getBatteryInfogetStorageSpacegetDeviceNamegetDeviceModelgetOSVersiongetScreenRealSizegetScreenScalegetOrientationgetScreenBrightnesssetVolumegetLanIpvibrate
system
Apps, URLs, clipboard, lock state, memory and CPU usage, notifications.
startAppstopAppactivateAppactivateAppInfogetInstalledAppListopenURLsetClipboardgetClipboardisLockedlockunlockgetMemoryInfogetCpuUsagenotify
ime
Type, paste, clear and read text through the ketec keyboard.
isOkinputpasteclearTextgetTextpressEnterpressDeldismissswitchKeyboard
ui
Show the settings page, toasts and dialogs; talk to the page from the script.
showhideshowToastconfirmconfirmInputalertonEventcalleval
pip
Floating picture-in-picture window with log, keep-alive and custom text modes.
isPipActiveswitchToLogModeswitchToKeepAliveModeswitchToCustomModesetCustomTextsetPositioncloseWindow
hotUpdatePython: hotupdate
Check for, download and install new versions of a script package.
checkUpdatedownloadAndInstallgetCurrentVersion
hid
Hardware mouse and keyboard through the ESP32-S3 accessory, plus accessory status.
clickdoubleClickmovemouseDownmouseUpswipeswipeCurveinputinputSimplesendKeypressButtonopenAppcloseAppopenURLrecenthomeScreenisUSBConnectedgetDeviceVersionresetPositionrestartDevice
httpPython: requests
GET, POST, JSON, file downloads and WebSocket connections.
httpGethttpPostpostJSONrequestdownloadFilenewWebsocket
cloud
Connect to your cloud control server, report data and receive events.
connectisConnecteddisconnectreportonEvent
mysql
Connect to MySQL, run queries and statements, use transactions.
connectqueryexecutebeginTransactioncommitrollbackdisconnect
sqlite
Local SQLite databases with queries and transactions.
openqueryexecutebeginTransactioncommitrollbackclose
file
Read, write and append files, line helpers, directories and package resources.
readFilewriteFileappendLinereadLinereadAllLinesdeleteLinelistDirmkdirsexistscopyfileMD5readResFilegetResFile
zipFile
List, create and extract ZIP archives.
zipunzipgetFileListisZip
plist
Read and edit property list files.
readwritegetsetremove
config
Script settings that persist between runs and keep their types.
getsetremoveallsetAll
cryptoUtils
AES and RSA encryption, MD5, SHA-1 and SHA-256.
encryptWithAES_ECBdecryptWithAES_ECBencryptWithRSAdecryptWithRSAmd5sha1sha256
paddleOcrPython: paddleocr
On-device PP-OCR for Chinese, English, Japanese, Korean and digits.
recognizeAbsfindTextAbsloadModelsetMaxSideLenfree
appleOcrPython: appleocr
The system Vision text recognizer.
recognizeAbsrecognizeNumbersAbsfindTextAbs
tomatoOcrPython: tomatoocr
Bundled open-model OCR with tap-point helpers. No license key.
ocrImagefindTapPointfindTapPointssetRecTypesetReturnTyperelease
dotOcrPython: dotocr
Dot-matrix OCR with fonts you load yourself.
loadFontrecognizeAbsfindTextAbsfreefreeAll
yolo
Run your own YOLO detection models on the screen or a region.
loaddetectAbsfreefreeAll
yoloClsPython: yolocls
Run YOLO classification models.
loadclassifyclassifyRegionfreefreeAll
cvPython: cv2
Around 140 OpenCV functions on Mat objects. In Python, use cv2 directly.
imreadcvtColorthresholdCannyfindContoursmatchTemplateresizeGaussianBlurinRangeORBSIFTdetectQRCode
ai
Configure LLM providers, then ask, judge, extract and chat.
setProvideraskjudgeextractchatparseJson
tts
Text to speech with system voices.
speakwaitEndstopisSpeakingsetVoicegetAvailableVoices
logger
Log levels, log files, file size and rotation.
debuginfowarnerrorsetLoggerLevelsetLogToFilesetMaxLogFileSize
media
Save to the photo library, clean up photos and videos, play audio.
saveImageToAlbumsaveVideoToAlbumPathdeleteAllPhotosdeleteAllVideosplayMp3stopMp3
threadPython: sharedState
Run functions in parallel threads; share values with sharedState.
runstopAllsharedState.setgetwithBatchclear
utils
Time formatting, random numbers, UUIDs, Base64 and hex helpers.
timeFormatrandomrandomUUIDbase64Encodedbase64DecodedhexString
Plus node methods such as label, labelMatch, type, xpath, clickCenter, scrollToVisible, parent and child on every selector result.
Every phone serves an HTTP API on port 9800 of its local address. Workbench uses the same endpoints, so anything it does, your own tools can do too.
Base address: http://<iphone-ip>:9800
| Method | Path | What it does |
|---|---|---|
| GET | /api/status | App status, version and device info |
| GET | /api/screenshot · /api/screenshotBase64 | Screenshot as JPEG (also as Base64) |
| GET | /mirror/image | Live MJPEG screen stream |
| POST | /api/runScript | Run a JavaScript snippet and return its result |
| GET | /api/run · /api/stop | Run or stop the loaded package |
| GET | /api/apps | List installed apps |
| GET | /api/getClipboard · /api/setClipboard | Read or write the clipboard |
| GET · POST | /api/getAllConfig · /api/setConfig | Read or change settings |
| Method | Path | What it does |
|---|---|---|
| GET | /api/control/click · /doubleClick | Tap or double tap at x, y |
| GET | /api/control/swipe | Swipe between two points |
| GET | /api/control/startApp · /stopApp · /activateApp | Start, stop or activate an app by bundle ID |
| GET | /api/control/home · /recent · /pressButton | Home screen, app switcher, hardware buttons |
| POST | /api/control/w3cActions | Standard W3C Actions, including multi-touch |
| GET | /api/source | UI tree as XML |
| Method | Path | What it does |
|---|---|---|
| GET | /api/hid/click · /doubleClick | Hardware tap or double tap |
| GET | /api/hid/move · /mouseDown · /mouseUp | Move the pointer, press and release |
| GET | /api/hid/swipe | Hardware swipe |
| POST · GET | /api/hid/sendKey · /input | Key combinations and text |
| GET | /api/hid/openApp · /closeApp · /openURL | Open or close an app by name, open a URL |
| GET | /api/hid/deviceInfo · /restartDevice | Accessory info and restart |
| Method | Path | What it does |
|---|---|---|
| GET | /api/ime/input · /paste · /clearText · /getText · /pressEnter · /pressDel | Type, paste, clear, read text, Enter and Delete |
| GET | /api/ime/isOk | Is the ketec keyboard on screen |
| Method | Path | What it does |
|---|---|---|
| GET · POST | /api/file/list · /upload · /download · /delete | List, upload, download and delete files |
| GET · POST | /api/media/saveImageToAlbum · /deleteAllPhotos | Save to or clean up the photo library |
| GET | /logger/current/lines · /logger/files · /logger/download | Live log lines, log files and downloads |
Agent endpoints need Agent mode and HID endpoints need HID mode. Endpoints act immediately, so be careful when probing a real device.
Full HTTP API reference · OpenAPI 3.1 (openapi.yaml) · openapi.json
Guide: Agent keep-alive · LAN mode — let one Linux host on your network keep ketec running on every phone, even after ketec is killed or the phone restarts.
Reach phones that are not on your desk.
Workbench generates an 8-digit code. Enter it on the phone under Settings › Remote Debugging and the phone appears in Workbench through the ketec relay. Either side can end the session.
Point the phone at your own frp server with TCP or STCP mapping, import settings from the clipboard and map automatically on launch. Idle sessions can disconnect after 5, 10, 30 or 60 minutes.
Set a cloud control address and the phone keeps a WebSocket connection to your server, which can run scripts, take screenshots and send input. Scripts report data with cloud.report and listen with cloud.onEvent.
Full API reference with every parameter and return value is coming soon.