# justapk

Multi-source APK downloader with automatic fallback. Downloads Android APK files by package name from 6 sources, trying each until one succeeds.

## Install

```bash
pip install justapk
```

Requires Python 3.11+.

## Usage

### Download

```bash
# Auto-select best source
justapk download org.telegram.messenger

# From a specific source
justapk download org.telegram.messenger -s apkpure

# To a specific directory
justapk download org.telegram.messenger -o ./apks/

# Keep XAPK as-is (don't auto-convert to APK)
justapk download com.termux -s apkpure --no-convert
```

### Search

```bash
justapk search telegram
justapk search telegram -s fdroid
```

### Info

```bash
justapk info org.telegram.messenger
justapk info org.telegram.messenger -s apkpure
```

### Convert XAPK to APK

```bash
justapk convert app.xapk
justapk convert app.xapk -o output/
```

Merges split APKs (base + native libs + assets) into a single APK and signs with a debug key.

### List sources

```bash
justapk sources
```

All commands output JSON to stdout. Progress goes to stderr.

## Sources

Tried in this order during fallback:

| # | Source | Method | Notes |
|---|--------|--------|-------|
| 1 | APK20 | Web + REST API | No Cloudflare |
| 2 | F-Droid | JSON API | FOSS apps only |
| 3 | APKPure | Mobile REST API | Largest catalog |
| 4 | APKMirror | Web scraping | Cloudflare (curl_cffi) |
| 5 | Uptodown | Mobile REST API + web token | No Cloudflare |
| 6 | APKCombo | Web scraping | Cloudflare (curl_cffi) |

## Python API

```python
from justapk import APKDownloader

dl = APKDownloader()

# Download with auto-fallback
result = dl.download("org.telegram.messenger", output_dir="./apks/")
print(result.path, result.size, result.sha256)

# Search across all sources
apps = dl.search("telegram")
for app in apps:
    print(app.package, app.name, app.source)

# Get info from first available source
info = dl.info("org.telegram.messenger")
print(info.name, info.version)

# Use specific source
result = dl.download("org.telegram.messenger", source="apkpure")
```

## License

MIT
