Last active
September 18, 2025 09:39
-
-
Save TheLastProject/2928889e4d8b8dba2afa92c6bc7253e4 to your computer and use it in GitHub Desktop.
Download apps from CleanAPK
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import sys | |
| import requests | |
| BASE_URL = "https://api.cleanapk.org/v2/" | |
| for package_id in sys.argv[1:]: | |
| app_details = requests.get(BASE_URL + "apps", params={ | |
| 'action': 'search', | |
| 'keyword': package_id, | |
| 'nres': 1, | |
| 'by': 'package_name' | |
| }).json() | |
| if not app_details['success']: | |
| print(f"Error getting app_details for {package_id}: {app_details['error']}") | |
| continue | |
| if len(app_details['apps']) != 1: | |
| print(f"Could not find {package_id} on CleanAPK. Requesting...") | |
| print(requests.post(BASE_URL + "app_suggestions", json={ | |
| 'package_name': package_id | |
| }).json()) | |
| continue | |
| apk_name = f"{package_id}_{app_details['apps'][0]['latest_version_code']}.apk" | |
| if os.path.isfile(apk_name): | |
| print(f"{package_id} is already up-to-date") | |
| continue | |
| download_info = requests.get(BASE_URL + "apps", params={ | |
| 'action': 'download', | |
| 'app_id': app_details['apps'][0]['_id'], | |
| 'version': app_details['apps'][0]['latest_version'] | |
| }).json() | |
| if not download_info['success']: | |
| print(f"Error getting download_info for {package_id}: {download_info['error']}") | |
| continue | |
| print(f"Downloading {apk_name}") | |
| r = requests.get(download_info['download_data']['download_link']) | |
| with open(apk_name, 'wb') as f: | |
| f.write(r.content) | |
| print(f"Finished downloading {apk_name}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment