npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

termux-api-library

v1.1.3

Published

Termux-api library for NodeJS

Downloads

41

Readme

termux-api-library

Termux-API library for NodeJS

install

  • Make sure you've first installed the termux and termux-api on your Android device from the f-droid or github releases.

  • To use Termux:API you also need to install the termux-api package.


pkg install termux-api
  • Finally get this node library

npm i --save termux-api-library

Example usage

library import

const api = require('termux-api-library');

or 

import api from 'termux-api-library';
  • isTermux Check if the device is Android (termux)
const isTermux = api.isTermux // return is true or false

if (isTermux) {

    await api.termux_wifi_connectioninfo((e) => {
        console.log(e);
    });

}
  • isTermuxApi check if termux-api is installed on your Android
await api.isTermuxApi((e) => {
    console.log(e); // return is true or false
});

or

const isTermuxApi = await api.isTermuxApi();
console.log(isTermuxApi); // return is true or false

Get the status of the device battery.


await api.termux_battery_status((e) => {

console.log(e);

});

Set the screen brightness between 0 and 255.


await api.termux_brightness(255);

List call log history.


await api.termux_call_log(10, (e) => {

console.log(e);

})

Get information about device camera(s).


await api.termux_camera_info((e) => {

console.log(e);

})

Take a photo and save it to a file in JPEG format.


await api.termux_camera_photo(0, './test.jpeg');

Get the system clipboard text.


await api.termux_clipboard_get((e) => {

console.log(e);

})

Set the system clipboard text.


await api.termux_clipboard_set("hello world")

List all contacts.


await api.termux_contact_list((e) => {

console.log(e);

})

Show a text entry dialog.


const hint = 'Put your password here'

const title = 'input password'

await api.termux_dialog(hint, title, false, true, true, (e) => {

console.log(e);

})
  • termux-download

Download a files


const url = 'https://example.com/image.jpeg'

const filename = 'photo_2022'

const savePath = '/data/data/com.termux/files/home'

await api.termux_download(url, filename, savePath);

Use fingerprint sensor on device to check for authentication.


await api.termux_fingerprint((e) => {

console.log(e);

})

Get the device location.


await api.termux_location("gps", "once", (e) => {

console.log(e);

})

or

const data = await api.termux_location('gps', 'once')

console.log(data);

Play media files.


const info = await api.termux_media_player.info();

console.log(info);

const play = await api.termux_media_player.play();

console.log(play);

const playFile = await api.termux_media_player.playFile(path);

console.log(playFile);

const pause = await api.termux_media_player.pause();

console.log(pause);

const stop = await api.termux_media_player.stop();

console.log(stop);

Recording using microphone on your device.


const info = await api.termux_microphone_record.info();

console.log(info);

const path = '/data/data/com.termux/files/home/filename.mp3'

const limit = 0

const start = await api.termux_microphone_record.start(path, limit);

console.log(start);

const stop = await api.termux_microphone_record.stop();

console.log(stop);
await api.termux_notification(title, text, id);
await api.termux_notification_remove(id);
  • termux-sensor Get information about types of sensors as well as live data.
await api.termux_sensor((e) => {
    console.log(e);
});

or

const sensor = await api.termux_sensor();
console.log(sensor);
  • termux-share Share a file specified as argument received on stdin.
const filepath = "../image.jpeg"
await api.termux_share('send', filepath);
const type = "inbox"
const limit = 10
const sender = undefined || "all" // the number for locate message : To display all senders, type the "all" or don't assign a value to the variable

await api.termux_sms_list(type, limit, sender, (e) => {
    console.log(e);
});

or

const list = await api.termux_sms_list(type, limit, sender);
console.log(list);
const number = 05592xxxxx
const slot = "0"
const text = "hello world"
await api.termux_sms_send(number, slot, text);
// connect
const number = 05592xxxxx
await api.termux_telephony_call.connect(number);

// Close call .

await api.termux_telephony_call.close();
  • termux-telephony-cellinfo Get information about all observed cell information from all radios on the device including the primary and neighboring cells.
const info = await api.termux_telephony_cellinfo();
console.log(info);
const deviceinfo = await api.termux_telephony_deviceinfo();
console.log(deviceinfo);
const position = "middle"
const background = "gray"
const text_color = "white"
const text = "hello world"
await api.termux_toast(position, background, text_color, text);
const values = "on" // on - enable torch. | off - disable torch.
await api.termux_torch(values);
  • termux-wifi-connectioninfo Print information about current Wi-Fi connection. This information include: SSID (AP name), BSSID (AP mac address), device IP and other.
await api.termux_wifi_connectioninfo((e) => {
    console.log(e);
});

or  

const wifi = await api.termux_wifi_connectioninfo();
console.log(wifi);
const values = true // true - enable Wi-Fi | false - disable Wi-Fi
await api.termux_wifi_enable(values);
await api.termux_wifi_scaninfo((e) => {
    console.log(e);
});

or  

const scaninfo = await api.termux_wifi_scaninfo();
console.log(scaninfo);

License

MIT license