Getting Started with API

This section introduces basic API usage, allowing you to understand another way to use FIRERPA.

FIRERPA provides up to 160 programming API interfaces, enabling meticulous management and operation of Android devices, covering over a dozen categories including command execution, system settings, system status, application-related, automation, proxy, and files. A fully encapsulated Python library is provided for a quick start. Before you begin, ensure that the FIRERPA server is running properly on your phone and that the FIRERPA client library lamda is installed as required.

Hint

Many API interfaces provided by the FIRERPA Python client library return native proto classes. You can directly access field values through the attributes of the output result, or refer to the proto definitions in the rpc directory to understand the attributes available under different results. For example, if a certain interface returns the following result, you can access specific fields as shown in the example.

>>> result = status.get_battery_info()
>>> print (result)
batt_charging: true
batt_percent: 100
batt_temperature: 26.899999618530273
>>> print (result.batt_temperature)
26.899999618530273

Connecting to the Device

Before connecting a device, you need to prepare some necessary information, such as the IP address that can reach your phone, and whether you used a server certificate when starting FIRERPA. Once you have this information, you can proceed with the following steps.

To instantiate the device, by default, simply provide an accessible IP address.

from lamda.client import *
d = Device("192.168.0.2")

If you enabled a server certificate or changed the port when starting the FIRERPA server, connect like this.

from lamda.client import *
d = Device("192.168.0.2", certificate="/path/to/lamda.pem", port=65000)

From now on, the d variable in the following text will always refer to this Device instance.

Simple Warm-up

Now, execute the following code, and it will launch the Settings app for you.

d.application('com.android.settings').start()

You can also use the following interface to make the device beep. This can conveniently help you locate the device when you have multiple ones.

d.beep()

Alright, now you have learned the basic usage. Continue reading to explore other available interfaces.