Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/termux/termux-app/llms.txt

Use this file to discover all available pages before exploring further.

Termux:API bridges the gap between the Linux terminal and the Android operating system. Once installed, it adds a set of termux-* commands that call Android APIs directly — so you can read GPS coordinates, send SMS messages, post notifications, control the camera, and interact with the clipboard entirely from shell scripts or the command line.

How it works

Termux:API consists of two parts that must both be installed:
  1. The Termux:API APK — a background Android app that handles API calls and holds the necessary Android permissions.
  2. The termux-api package — a set of shell wrapper scripts installed via pkg, which send requests to the APK via Unix sockets.
When you run a termux-* command in the terminal, the shell script passes the request to the APK, which uses Android APIs to fulfill it and returns the result to stdout.

Installation

1

Install the Termux:API APK

Download and install the Termux:API APK from the same source as your main Termux app (F-Droid or GitHub). Open the app once after installing to register it.
2

Install the termux-api package

In the Termux terminal, run:
pkg install termux-api
3

Grant permissions

Android will prompt for permissions the first time you run a command that requires them (location, camera, contacts, etc.). You can also grant them in advance via Android Settings → Apps → Termux:API → Permissions.

Available commands

The following commands are available after installing the termux-api package:
CommandDescription
termux-battery-statusReturns battery level, temperature, health, and charging status as JSON
termux-camera-photoTakes a photo using a device camera and saves it to a file
termux-clipboard-getPrints the current clipboard contents to stdout
termux-clipboard-setSets the clipboard to the provided text
termux-contact-listLists all contacts on the device as JSON
termux-dialogShows a dialog UI and returns the user’s input
termux-locationReturns current GPS or network location as JSON
termux-notificationPosts an Android notification
termux-sensorReads data from device sensors (accelerometer, gyroscope, etc.)
termux-sms-sendSends an SMS message to a phone number
termux-tts-speakSpeaks text aloud using Android’s text-to-speech engine
termux-vibrateVibrates the device
termux-wifi-connectioninfoReturns current Wi-Fi connection details as JSON

Usage examples

Check battery status:
termux-battery-status
{
  "health": "GOOD",
  "percentage": 87,
  "plugged": "UNPLUGGED",
  "status": "DISCHARGING",
  "temperature": 28.5
}
Get current location and extract coordinates with jq:
termux-location | jq '{lat: .latitude, lon: .longitude}'
Post a notification from a script:
termux-notification \
  --title "Backup complete" \
  --content "Files synced successfully at $(date +%H:%M)"
Send text to the clipboard:
echo "Hello from Termux" | termux-clipboard-set
termux-clipboard-get
Read accelerometer sensor data for 3 seconds:
termux-sensor -s "TYPE_ACCELEROMETER" -d 3000

Permissions reference

Each command requires specific Android permissions. They are requested at runtime when you first use a command:
  • Locationtermux-location
  • Cameratermux-camera-photo
  • Read contactstermux-contact-list
  • Send SMStermux-sms-send
  • Notificationstermux-notification (on Android 13+)
All termux-* commands output JSON by default. Pipe the output to jq for formatted or filtered results: pkg install jq.

Source code

The Termux:API source is available at github.com/termux/termux-api.

Build docs developers (and LLMs) love