Skip to content

cesarferreira/node-adb-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

node-adb-api

A Node.js API wrapper for ADB (Android Debug Bridge)

npm npm

Features

  • πŸ” List connected devices
  • πŸ“± Manage Android apps (launch, kill, clear data)
  • πŸ“¦ Download APKs from devices
  • πŸ”Ž Fuzzy search packages
  • ⚑ Fast and reliable

Installation

npm install node-adb-api

Usage

const adb = require('node-adb-api');

Device Management

// Get list of connected device serial numbers const devices = adb.getListOfDevices(); // Check if a device is connected const isConnected = adb.isAnyDeviceConnected('device_serial');

Package Management

// Get list of installed packages on a device const packages = adb.getPackagesByDeviceSerialNumber('device_serial'); // Fuzzy search packages const results = await adb.fuzzySearchPackages(null, 'chrome'); // Get APK path on device const path = adb.getDeviceApkPath('device_serial', 'com.example.app'); // Download APK from device const apkFile = adb.downloadAPK('device_serial', 'com.example.app');

App Control

// Launch an app adb.launchApp('com.example.app', 'device_serial'); // Force kill an app adb.forceKill('com.example.app', 'device_serial'); // Clear app data adb.clearData('com.example.app', 'device_serial'); // Uninstall an app adb.uninstall('com.example.app', 'device_serial');

API Reference

getListOfDevices()

Returns an array of connected device serial numbers.

isAnyDeviceConnected(deviceSerialNumber)

Checks if the specified device is connected.

  • deviceSerialNumber: Device serial number to check

getPackagesByDeviceSerialNumber(deviceSerialNumber)

Returns an array of package names installed on the device.

  • deviceSerialNumber: Target device serial number

fuzzySearchPackages(packages, textToFind)

Performs a fuzzy search on installed packages.

  • packages: Optional array of packages to search in
  • textToFind: Search query string

getDeviceApkPath(deviceSerialNumber, chosenPackage)

Gets the path of an APK file on the device.

  • deviceSerialNumber: Target device serial number
  • chosenPackage: Package name to locate

downloadAPK(deviceSerialNumber, chosenPackage)

Downloads an APK file from the device.

  • deviceSerialNumber: Target device serial number
  • chosenPackage: Package name to download
  • Returns: The downloaded APK filename

launchApp(chosenPackage, selectedDevice)

Launches an app on the device.

  • chosenPackage: Package name to launch
  • selectedDevice: Target device serial number

forceKill(chosenPackage, deviceSerialNumber)

Force stops an app on the device.

  • chosenPackage: Package name to force stop
  • deviceSerialNumber: Target device serial number

clearData(chosenPackage, deviceSerialNumber)

Clears app data on the device.

  • chosenPackage: Package name to clear data
  • deviceSerialNumber: Target device serial number

uninstall(chosenPackage, selectedDevice)

Uninstalls an app from the device.

  • chosenPackage: Package name to uninstall
  • selectedDevice: Target device serial number

Development

# Install dependencies npm install # Run tests npm test # Run linting npm run lint

Used in

purrge - 🐱 Quickly purrge android apps from your phone

License

MIT Β© Cesar Ferreira

About

A node API for adb (android debug bridge)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •