Command reference

Every Droidline command with its parameters, return value, errors and the same call in Python, Node.js, the CLI and HTTP.

Each entry shows what the command does, its parameters, what it returns and which errors it can raise, then the same call in every interface. Pick a language in any example and the whole page follows. The Python examples assume d = connect() (dl = Droidline() for server commands), and the Node.js examples assume const d = await connect() (const dl = new Droidline()).

Screen

dumpscreenshotcurrent

dump

Return the current screen as a node tree

NameTypeDefaultMeaning
pathstringSave the tree as JSON to this local file
all_windowsboolfalseInclude system windows such as the status bar and keyboard

Returns: an object with package, activity, width, height, tree

Needs: Accessibility service

d.dump("screen.json")   # saved on your PC

screenshot

Capture the screen

Android 11+ uses the accessibility screenshot. Android 9-10 asks once for screen capture permission.

NameTypeDefaultMeaning
pathstringSave the image to this local file. The extension picks png or jpeg
formatstring png | jpeg"jpeg"Image format
qualityint80JPEG quality 1-100
scalenumber1Resize factor 0.1-1.0, useful on mobile data

Returns: an object with format, width, height, data

Needs: Accessibility service

d.screenshot("shot.png")   # saved on your PC

current

Foreground package and activity

Returns: an object with package, activity

Needs: Accessibility service

d.current()

Coordinates

taplong_tapswipe

tap

Tap a screen coordinate

NameTypeDefaultMeaning
xintrequiredX in screen pixels
yintrequiredY in screen pixels

Returns: an object with ms

Needs: Accessibility service

d.tap(540, 1200)

long_tap

Press and hold a coordinate

NameTypeDefaultMeaning
xintrequiredX in screen pixels
yintrequiredY in screen pixels
msint800Hold time in milliseconds

Returns: an object with ms

Needs: Accessibility service

d.long_tap(540, 1200, 800)

swipe

Swipe between two points, or in a direction

NameTypeDefaultMeaning
x1int|stringrequiredStart X, or a direction: up, down, left, right
y1intStart Y
x2intEnd X
y2intEnd Y
msint300Duration in milliseconds

Returns: an object with ms

Needs: Accessibility service

d.swipe(540, 1600, 540, 400, 300)

Elements

touchlong_touchscroll_to

touch

Wait for an element and tap it

If the node refuses the click, the center of its bounds is tapped instead. via tells which path worked: node, parent or gesture.

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
nthint0Index when several elements match, starting at 0
timeoutnumber10 sSeconds to wait for the target to appear

Returns: an object with via, ms

Shorthand: touchById(value), touchByText(value), touchByDesc(value)

Errors: NOT_FOUND, NOT_CLICKABLE, NO_ACCESSIBILITY

Needs: Accessibility service

d.touch("text", "Log in")

long_touch

Wait for an element and press and hold it

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
msint800Hold time in milliseconds
nthint0Index when several elements match, starting at 0
timeoutnumber10 sSeconds to wait for the target to appear

Returns: an object with via, ms

Needs: Accessibility service

d.long_touch("text", "Message")

scroll_to

Scroll until an element is visible

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
directionstring down | up | left | right"down"Direction the content moves toward
max_swipesint20Give up after this many swipes
nthint0Index when several elements match, starting at 0

Returns: an object with swipes

Needs: Accessibility service

d.scroll_to("text", "Settings")

Input

inputclearsendkey

input

Wait for a field and set its text

Uses the accessibility set-text action. Fields that ignore it fall back to the Droidline keyboard when it is selected.

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
textstringrequiredText to enter
appendboolfalseKeep existing text and add to the end
nthint0Index when several elements match, starting at 0
timeoutnumber10 sSeconds to wait for the target to appear

Returns: an object with via, ms

Needs: Accessibility service

d.input("id", "email", "me@example.com")

clear

Empty a text field

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
nthint0Index when several elements match, starting at 0
timeoutnumber10 sSeconds to wait for the target to appear

Returns: an object with ms

Needs: Accessibility service

d.clear("id", "email")

sendkey

Send a key name, a key code, or text

back, home, recents, notifications, quick_settings and lock use accessibility global actions. Other keys and text go through the Droidline keyboard to the focused field.

NameTypeDefaultMeaning
keystring|intKey name (enter, tab, del, space, escape, up, down, left, right, back, home...), Android key code, or text to type
textstringType this text literally, even if it equals a key name

Returns: an object with via

Errors: NO_IME, BAD_ARGS

Needs: Accessibility service

d.sendkey("enter")

Checks

existswaitwait_goneget_text

exists

Whether an element is on screen right now. Never waits

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
nthint0Index when several elements match, starting at 0

Returns: a value of type bool

Needs: Accessibility service

d.exists("text", "Close ad")

wait

Wait until an element appears

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
timeoutnumber10 sSeconds to wait for the target to appear
nthint0Index when several elements match, starting at 0

Returns: an object with ms

Errors: NOT_FOUND

Needs: Accessibility service

d.wait("text", "Done", timeout=30)

wait_gone

Wait until an element disappears

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
timeoutnumber10 sSeconds to wait for the target to appear

Returns: an object with ms

Errors: TIMEOUT

Needs: Accessibility service

d.wait_gone("text", "Loading")

get_text

Text of an element, or an empty string

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
nthint0Index when several elements match, starting at 0

Returns: a value of type string

Needs: Accessibility service

d.get_text("id", "balance")

Conditions

checkedenabledselectedcountwhichin_appkeyboard_shownlast_toastcolor

checked

true if a switch or checkbox is on

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
nthint0Index when several elements match, starting at 0

Returns: a value of type bool

Needs: Accessibility service

d.checked("id", "auto_login")

enabled

true if the element can be pressed

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
nthint0Index when several elements match, starting at 0

Returns: a value of type bool

Needs: Accessibility service

d.enabled("text", "Next")

selected

true if a tab or item is selected

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match
nthint0Index when several elements match, starting at 0

Returns: a value of type bool

Needs: Accessibility service

d.selected("text", "Home")

count

Number of matching elements

NameTypeDefaultMeaning
byselectorrequiredWhich dump field to match: text, textContains, id, desc, descContains, class
valuestringrequiredThe value to match

Returns: a value of type int

Needs: Accessibility service

d.count("class", "android.widget.CheckBox")

which

Index of the first candidate to appear, or -1

NameTypeDefaultMeaning
candidateslist<selector_pair>requiredList of [by, value] pairs
timeoutnumber10 sSeconds to wait for any candidate

Returns: a value of type int

Needs: Accessibility service

d.which([("text", "Log in"), ("id", "main_tab")], timeout=15)

in_app

true if that app is in the foreground

NameTypeDefaultMeaning
packagestringrequiredPackage name, for example com.android.chrome

Returns: a value of type bool

Needs: Accessibility service

d.in_app("com.android.chrome")

keyboard_shown

true if a soft keyboard is showing

Returns: a value of type bool

Needs: Accessibility service

d.keyboard_shown()

last_toast

Text of the most recent toast, or an empty string

NameTypeDefaultMeaning
max_agenumber30 sIgnore toasts older than this many seconds

Returns: a value of type string

Needs: Accessibility service

d.last_toast()

color

Pixel color at a coordinate as #RRGGBB

For screens without accessibility nodes, such as games.

NameTypeDefaultMeaning
xintrequiredX in screen pixels
yintrequiredY in screen pixels

Returns: a value of type string

Needs: Accessibility service

d.color(540, 1200)

Device

screen_onlockedwakelockbatteryorientationinfo

screen_on

true if the screen is on

Returns: a value of type bool

d.screen_on()

locked

true if the lock screen is showing

Returns: a value of type bool

d.locked()

wake

Turn the screen on and dismiss a lock screen that has no PIN

Gestures fail while the screen is off. A PIN, pattern or password lock cannot be dismissed without the user.

Returns: an object with screen_on, locked

d.wake()

lock

Turn the screen off and lock

Returns: nothing

Needs: Accessibility service

d.lock()

battery

Battery level and charging state

Returns: an object with level, charging, temperature

d.battery()

orientation

portrait or landscape

Returns: a value of type string

d.orientation()

info

Model, Android version, screen size and permission readiness

Returns: an object with model, manufacturer, sdk, release, agent, width, height, ready

d.info()

Network

networkproxyproxy_check

network

Connection type (wifi, mobile, none) and airplane mode

Returns: an object with type, airplane, metered

d.network()

proxy

Route chosen apps through an upstream proxy with a per-app VPN

Supports http:// (CONNECT) and socks5:// with user:pass. Pass null or "off" to stop. One upstream at a time. Apps that ignore the proxy setting lose network access instead of leaking.

NameTypeDefaultMeaning
urlstring|nullrequiredsocks5://user:pass@host:port, http://host:port, a saved profile like @kr1, or off
appstring|list<string>Package or packages to route

Returns: an object with active, apps

Errors: NO_PERMISSION, PROXY_FAILED, UNSUPPORTED

Needs: VPN permission · Android API 29+

d.proxy("@kr1", app="com.android.chrome")

proxy_check

Per-app proxy state and the IP the outside world sees

NameTypeDefaultMeaning
appstringPackage to check

Returns: an object with active, ip, upstream, error

d.proxy_check("com.android.chrome")

Apps

launchopen_urlkillclear_dataappsinstalled

launch

Start an app, optionally at a specific activity

NameTypeDefaultMeaning
packagestringrequiredPackage name, for example com.android.chrome
activitystringActivity name, either full or starting with a dot

Returns: an object with ms

Errors: APP_NOT_FOUND, ACTIVITY_BLOCKED

d.launch("com.android.settings")

open_url

Open a URL or deep link

NameTypeDefaultMeaning
urlstringrequiredhttp(s) URL or app deep link
packagestringOpen with this app only

Returns: nothing

d.open_url("https://droidline.dev")

kill

Force stop an app

Runs a settings macro: App info, Force stop, OK. Takes a few seconds.

NameTypeDefaultMeaning
packagestringrequiredPackage name, for example com.android.chrome

Returns: an object with via, ms

Errors: APP_NOT_FOUND, MACRO_FAILED

Needs: Accessibility service

d.kill("com.android.chrome")

clear_data

Clear an app's data

Runs a settings macro: App info, Storage, Clear data, OK.

NameTypeDefaultMeaning
packagestringrequiredPackage name, for example com.android.chrome

Returns: an object with via, ms

Errors: APP_NOT_FOUND, MACRO_FAILED

Needs: Accessibility service

d.clear_data("com.android.chrome")

apps

Installed packages

NameTypeDefaultMeaning
systemboolfalseInclude system packages

Returns: a value of type list<app>

d.apps()

installed

Version name if installed, empty string if not

NameTypeDefaultMeaning
packagestringrequiredPackage name, for example com.android.chrome

Returns: a value of type string

d.installed("com.android.chrome")

System

backhomerecentsopen_notificationsquick_settingsdatawifiairplaneclipboardbatch

back

Back

Returns: nothing

Needs: Accessibility service

d.back()

home

Home screen

Returns: nothing

Needs: Accessibility service

d.home()

recents

Recent apps

Returns: nothing

Needs: Accessibility service

d.recents()

open_notifications

Pull down the notification shade

Returns: nothing

Needs: Accessibility service

d.open_notifications()

quick_settings

Open quick settings

Returns: nothing

Needs: Accessibility service

d.quick_settings()

data

Turn mobile data on or off

Cuts the phone's own connection. The call answers accepted first; pass wait to get the final result instead.

NameTypeDefaultMeaning
onboolrequiredtrue to turn on, false to turn off

Returns: an object with via, ms

Errors: MACRO_FAILED

Needs: Accessibility service

d.data(False, wait=True)

wifi

Turn Wi-Fi on or off

Cuts the phone's own connection. The call answers accepted first; pass wait to get the final result instead.

NameTypeDefaultMeaning
onboolrequiredtrue to turn on, false to turn off

Returns: an object with via, ms

Errors: MACRO_FAILED

Needs: Accessibility service

d.wifi(False, wait=True)

airplane

Turn airplane mode on or off

To renew the IP, put on and off in one batch so the phone runs both while offline.

Cuts the phone's own connection. The call answers accepted first; pass wait to get the final result instead.

NameTypeDefaultMeaning
onboolrequiredtrue to turn on, false to turn off

Returns: an object with via, ms

Errors: MACRO_FAILED

Needs: Accessibility service

d.airplane(True, wait=True)

clipboard

Write the clipboard, or read it when called without text

Reading on Android 10+ needs the Droidline keyboard to be the current input method.

NameTypeDefaultMeaning
textstringText to copy. Omit to read

Returns: a value of type string

Errors: NO_IME

d.clipboard("Hello")

batch

Run several commands on the phone in one go, even while it is offline

Steps are [cmd, args...] lists or {cmd, ...} objects. The step sleep(ms) only exists inside batch. If a step cuts the network, the call returns accepted and the result arrives after reconnect.

NameTypeDefaultMeaning
stepslist<step>requiredCommands to run in order
stop_on_errorbooltrueStop at the first failing step

Returns: an object with results

d.batch([("airplane", True), ("sleep", 3000), ("airplane", False)], wait=True)

Chrome

chrome.go

chrome.go

Open a URL in Chrome

NameTypeDefaultMeaning
urlstringrequiredAddress. https:// is added if missing
new_tabboolfalseOpen in a new tab

Returns: an object with ms

Errors: APP_NOT_FOUND

d.chrome.go("droidline.dev")

Notifications

notificationshas_notificationwait_notificationnotification_replynotification_clicknotification_dismissnotify_filteron_notification

notifications

Notifications currently showing

NameTypeDefaultMeaning
packagestringOnly this app

Returns: a value of type list<notification>

Needs: Notification access

d.notifications()

has_notification

true if a showing notification matches

NameTypeDefaultMeaning
bystring text | textContains | title | packagerequiredtext and textContains look at both title and text
valuestringrequiredThe value to match

Returns: a value of type bool

Needs: Notification access

d.has_notification("textContains", "shipped")

wait_notification

Wait for a matching notification and return it

Handled by the PC server, so it does not block other commands to the phone. On Android 15+ the OS hides one-time codes from apps: you get the notification but the code is masked.

NameTypeDefaultMeaning
bystring text | textContains | title | packagerequiredtext and textContains look at both title and text
valuestringrequiredThe value to match
timeoutnumber60 sSeconds to wait
packagestringOnly from this app

Returns: a value of type notification

Errors: TIMEOUT

Needs: Notification access

dl.wait_notification("textContains", "verification code", 60)

notification_reply

Reply inline to a notification that has a reply action

NameTypeDefaultMeaning
keystringrequiredNotification key from notifications() or a notification event
textstringrequiredReply text

Returns: nothing

Needs: Notification access

n = d.notifications()[0]
d.notification_reply(n["key"], "On my way")

notification_click

Open a notification

NameTypeDefaultMeaning
keystringrequiredNotification key from notifications() or a notification event

Returns: nothing

Needs: Notification access

n = d.notifications()[0]
d.notification_click(n["key"])

notification_dismiss

Dismiss a notification

NameTypeDefaultMeaning
keystringrequiredNotification key from notifications() or a notification event

Returns: nothing

Needs: Notification access

n = d.notifications()[0]
d.notification_dismiss(n["key"])

notify_filter

Choose which apps' notifications are sent to the PC. Default is none

NameTypeDefaultMeaning
packageslist<string>Allowed packages. Omit to read the current list

Returns: a value of type list<string>

Needs: Notification access

d.notify_filter(["com.android.chrome", "com.google.android.gm"])

on_notification

Call a function for every matching notification

SDK only. Built on subscribe. The CLI prints matching notifications as JSON lines instead.

Runs inside the SDK; the server sees a subscribe line.

NameTypeDefaultMeaning
packagestringOnly from this app
textContainsstringOnly if title or text contains this

Returns: nothing

Needs: Notification access

stop = d.on_notification(package="com.google.android.gm", callback=print)
# ... later
stop()

Server

devicespairpair_qrrenamerevokesubscribeserver_infoauth

devices

Paired devices with online state and route

Returns: a value of type list<device>

dl.devices()

pair

Approve the phone that shows this 6-digit code

NameTypeDefaultMeaning
codestringrequiredCode shown on the phone
namestringName to give the device

Returns: a value of type device

Errors: PAIRING_FAILED

dl.pair("482913", name="shelf-01")

pair_qr

Create a one-time pairing QR code valid for 10 minutes

NameTypeDefaultMeaning
namestringName to give the device

Returns: an object with uri, expires

dl.pair_qr()

rename

Give a device a name

NameTypeDefaultMeaning
devicestringrequiredDevice ID or name
namestringrequiredNew name

Returns: a value of type device

dl.rename("k7d2q9xa", "shelf-01")

revoke

Unpair a device. It must pair again to connect

NameTypeDefaultMeaning
devicestringrequiredDevice ID or name

Returns: nothing

dl.revoke("shelf-01")

subscribe

Receive events on this connection

NameTypeDefaultMeaning
eventslist<string>requiredAny of notification, screen, toast, device, result
devicestringOnly from this device. Omit for all

Returns: nothing

dl.subscribe(["notification"])

server_info

Server version, ports and listening addresses

Returns: an object with version, server, name, proto, agent_port, client_port

dl.server_info()

auth

Authenticate this client connection with a token

NameTypeDefaultMeaning
tokenstringrequiredClient token from droidline token

Returns: nothing

dl.auth("your-client-token")