Skip to content

marzzzello/playstoreapi

Repository files navigation

Repo on GitLab Repo on GitHub license commit-activity Mastodon Follow

Google Play Store Python API

This project is fork of googleplay-api. It contains an unofficial API for google play interactions.

This fork was created to have a better base for the gplaycrawler.

The code was updated with the following changes:

  • add (anonymous) login via token dispenser
  • add login via environment variables
  • updated protobuf and device configuration (they are now the same as the GPlayApi from AuroraOSS)
  • remove python2 support
  • raise exceptions for bad HTTP status codes
  • add possibility to use a delay between requests
  • add streamDetails (used for related apps)
  • add support for next pages to search and streamDetails

Setup

Install playstoreapi using pip:

$ pip install playstoreapi

Or clone the repo and run:

$ python setup.py build

Usage

Check scripts in test and examples directory for more examples on how to use this API.

from playstoreapi.googleplay import GooglePlayAPI

mail = '[email protected]'
passwd = 'mypasswd'

api = GooglePlayAPI('en_GB', 'Europe/London')
api.login(email=mail, password=passwd)
print(f'authSubToken: {api.authSubToken} gsfId: {api.gsfId}')

result = api.search('firefox')
for doc in result:
    if 'id' in doc:
        print('doc: {}'.format(doc['id']))
    for cluster in doc['subItem']:
        print('\tcluster: {}'.format(cluster['id']))
        for app in cluster['subItem']:
            print('\t\tapp: {}'.format(app['id']))

For first time logins, you should only provide email and password. The module will take care of initalizing the api, upload device information to the google account you supplied, and retrieving a Google Service Framework ID (which, from now on, will be the android ID of your fake device).

For the next logins you should save the gsfId and the authSubToken, and provide them as parameters to the login function or set them as environement variables. If you login again with email and password, this is the equivalent of re-initalizing your android device with a google account, invalidating previous gsfId and authSubToken.

Environment variables

# for envLogin()
export PLAYSTORE_TOKEN='ya29.fooooo'
export PLAYSTORE_GSFID='1234567891234567890'
export PLAYSTORE_DISPENSER_URL='http://goolag.store:1337/api/auth'

# requests
export HTTP_PROXY='http://localhost:8080'
export HTTPS_PROXY='http://localhost:8080'
export CURL_CA_BUNDLE='/usr/local/myproxy_info/cacert.pem'