
Exposing Termux API Features over HTTP
termux-api-http is a Node.js bridge from HTTP requests to Android system features exposed by Termux:API. It reports battery, Wi-Fi, location, and device information; triggers toast messages, vibration, and notifications; and exposes contacts, SMS, call logs, and clipboard access.
Install in Termux
Install Termux, its Termux:API add-on, the command package, and Node.js:
pkg install termux-api nodejs
npm install
Create .env with a strong key and a deliberate bind address:
PORT=3000
BIND_IP=127.0.0.1
API_KEY=replace_with_a_long_random_value
Start the server with node server.js. Authenticated calls use the X-API-Key header:
curl -H "X-API-Key: your_key" http://localhost:3000/api/battery
This API crosses a serious trust boundary. Contacts, messages, call logs, location, clipboard contents, notifications, and hardware controls are sensitive. Plain HTTP exposes the key and response data to the network, so do not bind the service publicly. Use loopback for local integrations or place it behind authenticated HTTPS with tight network access. Header authentication is preferable to a query parameter because URLs are commonly logged.
Visit the termux-api-http repository for the complete endpoint list and current security notes.