Custom Scripts
The built-in scripts cover the common flows. When you need something they do not — a step in a different order, a screen they never touch, or an app that is not TikTok or Instagram — you can write it yourself in any language and let TikMatrix hand you the phone.
Requirements
Custom scripts require a Pro, Team, or Business plan. Starter plan does not have access.
Your plan's device count is also the concurrency limit: a Pro plan (20 devices) can drive 20 phones at once, whether through built-in tasks, custom scripts, or a mix of both.
Two ways to run a script
Standalone
You run your program yourself. TikMatrix just lends you devices.
from tikmatrix import TikMatrix
client = TikMatrix()
for device in client.devices():
if device["busy"]:
continue
with client.device(device["serial"], label="my crawler") as d:
d.press("home")
print(d.info())
Good for one-off jobs, data collection, and anything you want to run from your own scheduler.
Managed
You register the program in TikMatrix and it becomes a task like any other. It gets the task queue, per-plan concurrency, automatic retries, the task log, and schedule templates. TikMatrix leases the device before starting your program and passes the lease id in its environment.
from tikmatrix import TikMatrix
with TikMatrix.from_env() as d: # device already leased
d.click(text="Log in")
print("done") # this line lands in the task log
Good for anything you want to run repeatedly, on a schedule, or across many devices.
Getting started
1. Install the client library
pip install requests
Then copy tikmatrix.py from the SDK directory next to your script. The library is a single file with no other dependencies.
You do not have to use it — the API is plain JSON over HTTP, and the raw endpoints are documented below.
2. Write your script
from tikmatrix import TikMatrix
client = TikMatrix()
with client.device("192.168.1.5:5555") as d:
d.press("home")
d.adb("shell", "am", "start", "-a", "android.settings.SETTINGS")
d.wait_for(text="Settings", timeout=15)
d.screenshot("settings.png")
3. Register it (managed mode only)
Go to Devices → Custom Scripts → Add Script:
| Field | Meaning |
|---|---|
| Name | Shown in the script list and the task log |
| Command | The program line to run, e.g. python C:/scripts/my_flow.py |
| Working directory | Optional. Where the program starts |
| Platform | See platform modes below |
| Timeout | Seconds before the script is killed and the task marked failed. Default 1800 |
| Extra environment variables | Optional JSON object merged into the program's environment |
Then press ▶ on the script row and pick your devices, exactly like a built-in script.