Metadata-Version: 2.5
Name: download-apk
Version: 0.3.0
Summary: Search Google Play and download apps' APKs into versioned folders.
Project-URL: Homepage, https://github.com/jeremy-morren/download-apk
Project-URL: Source, https://github.com/jeremy-morren/download-apk/tree/v0.3.0
Project-URL: Documentation, https://github.com/jeremy-morren/download-apk/blob/v0.3.0/README.md
Project-URL: Changelog, https://github.com/jeremy-morren/download-apk/releases/tag/v0.3.0
Project-URL: Issues, https://github.com/jeremy-morren/download-apk/issues
Author: Jeremy Morren
License-Expression: MIT
License-File: LICENSE
Keywords: android,apk,apkeep,download,google-play
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: MacOS
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Utilities
Requires-Python: >=3.10
Requires-Dist: google-play-scraper<2,>=1.2.7
Requires-Dist: patchright>=1.50
Description-Content-Type: text/markdown

# download-apk

Searches Google Play and download an app's APKs from the command line.

```
download-apk search firefox
download-apk download org.mozilla.firefox
```

Each download goes to `apps/<appId>/<version>/` and holds the base APK, its split APKs, and a `metadata.json` 
with each file's SHA-256. Running a download again picks up a new release. Google Play does not allow
downloading historic versions, so only the current version can be downloaded.

## Requirements

- Python 3.10 or later, on Windows, macOS or Linux (x64 or arm64).
- Google Chrome, for the one-time sign-in.
- A Google account. Use a spare one: Google may flag accounts that download apps outside a phone.

## Install

```
pip install download-apk
```

## Use

### Search

```
download-apk search firefox --limit 3
```

```
App ID                    Title                           Developer  Installs     Rating  Price
------------------------  ------------------------------  ---------  -----------  ------  -----
org.mozilla.focus         Firefox Focus: No Fuss Browser  Mozilla    10,000,000+  4.7     Free
org.mozilla.firefox_beta  Firefox Beta for Testers        Mozilla    10,000,000+  4.6     Free
org.mozilla.fenix         Firefox Nightly for Developers  Mozilla    1,000,000+   4.5     Free
```

`--limit` sets how many results to show (default 20).

### Download

```
download-apk download com.example.app
```

```
Downloading com.example.app from Google Play...
Saved com.example.app 1.4.2 to /home/me/apks/apps/com.example.app/1.4.2
```

To save somewhere other than `./apps`, pass `--out FOLDER`, or set `DOWNLOAD_APK_DIR` for every run.

Google Play only serves an app's current version. Paid apps download only if the account owns them.

### Options

| Option            | Default              | What it does                                     |
|-------------------|----------------------|--------------------------------------------------|
| `--ini PATH`      | `./.google-play.ini` | Where the sign-in token is saved                 |
| `--sign-in`       |                      | Sign in again, replacing the saved token         |
| `--email ADDRESS` | asked for            | The Google account's email, used when signing in |
| `--country CODE`  | detected             | The store country, e.g. `us`                     |
| `--lang CODE`     | detected             | The store language, e.g. `en` or `en-GB`         |

The country is detected from your IP address (through Cloudflare, or ipinfo.io as a fallback), and the
language from your system's display language. Each run prints what it picked.

## Signing in

The first time you run a command, Chrome opens on Google's sign-in page. Sign in, and the window
closes by itself; then type the account's email when asked. A token is saved to `.google-play.ini`,
and later runs reuse it. If Google stops accepting it, the sign-in runs again.

`.google-play.ini` works like a password for the account, so keep it out of git: add it to
`.gitignore`. download-apk warns you if the file is tracked by git, or would be on the next `git add`.

## Troubleshooting

- **"Google Play has no app …, or doesn't offer it to this account."** Check the app ID with
  `search`. Some apps are limited to certain countries or devices.
- **"Google Play refused the saved sign-in."** Run again with `--sign-in`.
- **Chrome doesn't open.** Install Google Chrome.

## Develop

```
git clone https://github.com/jeremy-morren/download-apk
cd download-apk
python -m venv .venv
source .venv/bin/activate                              # Windows: .venv\Scripts\activate
DOWNLOAD_APK_SKIP_APKEEP=1 pip install -e . --group test
pytest
```

The tests run offline and don't need apkeep. To run real downloads from a checkout, install without
`DOWNLOAD_APK_SKIP_APKEEP`: that compiles apkeep, which needs [Rust](https://rustup.rs).

## Acknowledgements

This tool uses the EFF's [apkeep](https://github.com/EFForg/apkeep) to download from Google Play 
and [google-play-scraper](https://github.com/JoMingyu/google-play-scraper) to search.

## License

[MIT](https://github.com/jeremy-morren/download-apk/blob/v0.3.0/LICENSE).
