# node-adb-api

> a node API for adb

Latest version **1.3.0** (published 2025-01-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-adb-api
pnpm add node-adb-api
yarn add node-adb-api
bun add node-adb-api
```

## Health

**Score 35/100 (D)** — status: stable.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.3.0 |
| Published | 2025-01-30 |
| First published | 2017-10-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 123.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Cesar Ferreira |
| Maintainers | cesarferreira |

## Links

- npm: https://www.npmjs.com/package/node-adb-api
- Repository: https://github.com/cesarferreira/node-adb-api
- Homepage: https://github.com/cesarferreira/node-adb-api#readme
- Issues: https://github.com/cesarferreira/node-adb-api/issues
- npm.io page: https://npm.io/package/node-adb-api

## Dependencies (4)

- [chalk](https://npm.io/package/chalk.md) ^2.2.0
- [fuzzy](https://npm.io/package/fuzzy.md) ^0.1.3
- [shelljs](https://npm.io/package/shelljs.md) ^0.8.5
- [node-time-log](https://npm.io/package/node-time-log.md) ^1.0.3

## Recent versions

- 1.3.0 (latest) — 2025-01-30
- 1.2.0 — 2024-06-20
- 1.1.4 — 2019-09-16
- 1.1.3 — 2017-10-20
- 1.1.2 — 2017-10-20
- 1.1.1 — 2017-10-19
- 1.1.0 — 2017-10-19
- 1.0.0 — 2017-10-18

## README

# node-adb-api
> A Node.js API wrapper for ADB (Android Debug Bridge)

[![npm](https://img.shields.io/npm/dt/node-adb-api.svg)](https://www.npmjs.com/package/node-adb-api)
[![npm](https://img.shields.io/npm/v/node-adb-api.svg)](https://www.npmjs.com/package/node-adb-api)

## Features
- 🔍 List connected devices
- 📱 Manage Android apps (launch, kill, clear data)
- 📦 Download APKs from devices
- 🔎 Fuzzy search packages
- ⚡ Fast and reliable

## Installation

```bash
npm install node-adb-api
```

## Usage

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

### Device Management
```javascript
// 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
```javascript
// 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
```javascript
// 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

```bash
# Install dependencies
npm install

# Run tests
npm test

# Run linting
npm run lint
```

## Used in
[purrge](https://github.com/cesarferreira/purrge) - 🐱 Quickly purrge android apps from your phone

## License
MIT © [Cesar Ferreira](http://cesarferreira.com)

---
_Source: https://npm.io/package/node-adb-api · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
