https://github.com/rycus86/googleplay-proxy
Python Flask application to proxy calls to the Google Play Store.
https://github.com/rycus86/googleplay-proxy
Last synced: 8 months ago
JSON representation
Python Flask application to proxy calls to the Google Play Store.
- Host: GitHub
- URL: https://github.com/rycus86/googleplay-proxy
- Owner: rycus86
- License: mit
- Created: 2017-06-12T21:51:50.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-02-15T17:59:14.000Z (over 8 years ago)
- Last Synced: 2025-01-23T18:16:08.459Z (over 1 year ago)
- Language: Python
- Size: 39.1 KB
- Stars: 3
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Google Play Proxy
A simple `Python` [Flask](http://flask.pocoo.org) *REST* server to proxy calls to the *Google Play Store*.
[](https://travis-ci.org/rycus86/googleplay-proxy)
[](https://hub.docker.com/r/rycus86/googleplay-proxy)
[](https://coveralls.io/github/rycus86/googleplay-proxy?branch=master)
[](https://codeclimate.com/github/rycus86/googleplay-proxy)
## Usage
The API is implemented using [googleplay-api](https://github.com/NeroBurner/googleplay-api)
and supports these environment variables:
- `GOOGLE_USERNAME`: a valid *Google* username
- `GOOGLE_PASSWORD`: password for the same *Google* account
- `ANDROID_ID`: a valid *Google Service Framework (GSF)* ID
*You can find it using the [Device ID app](https://play.google.com/store/apps/details?id=com.evozi.deviceid) for example*
- `MAX_LOGIN_RETRIES`: the maximum number of retries when login fails
*Login can be quite flaky*
To get a reference to the `ApiClient` class use something like:
```python
api = ApiClient(android_id=os.environ.get('ANDROID_ID'),
username=os.environ.get('GOOGLE_USERNAME'),
password=os.environ.get('GOOGLE_PASSWORD'),
max_login_retries=int(os.environ.get('MAX_LOGIN_RETRIES', '10')))
```
The `api.ApiClient` class wraps remote calls with the following methods:
- `login()`:
Executes the login (with retries) and caches the authentication token for following calls.
- `search(package_prefix)`:
Searches for applications using `package_prefix` and filters the result list to
only include apps whose package name starts with that prefix.
- `get_details(package_name)`:
Returns the details of the application whose package is `package_name`.
The `app` module is responsible for the *REST* presentation layer exposing *JSON* endpoints.
The exposed endpoints are cached using [Flask-Cache](https://pythonhosted.org/Flask-Cache).
Instead of the API a *scraper* can also be used (without authentication)
by setting the `API_TYPE` environment variable to `scraper`.
Programmatically:
```python
api = Scraper(cache_max_age=int(os.environ.get('MAX_CACHE_AGE', 24 * 60 * 60)))
```
The exposed methods are similar to the `ApiClient` class methods:
- `search(package_prefix)`:
Searches for applications using `package_prefix` and filters the result list to
only include apps whose package name starts with that prefix.
- `developer(developer_name)`:
Searches for applications developed by `developer_name`.
Returns results in the same format as `search`.
- `get_details(package_name)`:
Returns the details of the application whose package is `package_name`.
Configuration options:
- `HTTP_HOST`: the host (interface) for *Flask* to bind to (default: `127.0.0.1`)
- `HTTP_PORT`: the port to bind to (default: `5000`)
- `CORS_ORIGINS`: comma separated list of *origins* to allow *cross-domain* `GET` requests from
(default: `http://localhost:?.*`)
To allow connections from other hosts apart from `localhost` set the `HTTP_PORT` environment
variable to `0.0.0.0` or as appropriate.
List of endpoints:
- `/search/`:
returns a list of application details whose package starts with the given prefix
- `/developer/`:
returns a list of application details created by the given developer
- `/details/`:
returns the details of the application with the given package name
## Docker
The web application is built as a *Docker* image too based on *Alpine Linux*
for 3 architectures with the following tags:
- `latest`: for *x86* hosts
[](https://microbadger.com/images/rycus86/googleplay-proxy "Get your own image badge on microbadger.com")
- `armhf`: for *32-bits ARM* hosts
[](https://microbadger.com/images/rycus86/googleplay-proxy:armhf "Get your own image badge on microbadger.com")
- `aarch64`: for *64-bits ARM* hosts
[](https://microbadger.com/images/rycus86/googleplay-proxy:aarch64 "Get your own image badge on microbadger.com")
`latest` is auto-built on [Docker Hub](https://hub.docker.com/r/rycus86/googleplay-proxy)
while the *ARM* builds are uploaded from [Travis](https://travis-ci.org/rycus86/googleplay-proxy).
To run it:
```shell
docker run -d --name="googleplay-proxy" -p 5000:5000 \
-e GOOGLE_USERNAME='user' -e GOOGLE_PASSWORD='pass' -e ANDROID_ID='aid' \
-e CORS_ORIGINS='http://site.example.com,*.website.com' \
rycus86/googleplay-proxy:latest
```
Or to scrape:
```shell
docker run -d --name="googleplay-proxy" -p 5000:5000 \
-e API_TYPE=scrape \
-e CORS_ORIGINS='http://site.example.com,*.website.com' \
rycus86/googleplay-proxy:latest
```
Or with *docker-compose* (for a *Raspberry Pi* for example):
```yaml
version: '2'
services:
googleplay-proxy:
image: rycus86/googleplay-proxy:armhf
read_only: true
expose:
- "5000"
restart: always
environment:
- HTTP_HOST=0.0.0.0
env_file:
- googleplay-secrets.env
```
This way you can keep the secrets in the `env_file` instead of passing them to the *Docker*
client from the command line.