Skip to main content

API for integration with Yandex AppMetrica

Project description

Application for integrating with Yandex AppMetrica https://appmetrica.yandex.ru/

Yandex Docs https://tech.yandex.ru/appmetrica/doc/mobile-api/push/use-cases-docpage/

https://travis-ci.org/MyBook/appmetrica.svg?branch=master https://codecov.io/gh/MyBook/appmetrica/branch/master/graph/badge.svg

Before using API it is necessary:

  1. Get application id from your account in appmetrica.yandex.ru

  2. [Generate access token](https://tech.yandex.ru/appmetrica/doc/mobile-api/intro/authorization-docpage/)

Send push

  1. Create API instance:

    from appmetrica.push.api import PushAPI
    
    api = PushAPI(application_id, access_token)
  2. Create group to combine the sending in the report:

    group_id = api.create_group('test-push-1')
  3. Pass group_id, device list and message to send_push method and call:

    from appmetrica.push.api import TokenTypes
    
    transfer_id = api.send_push(group_id, devices=devices, ios_message=ios_message,
                                android_message=android_message, tag='harry potter')
    
    devices - list of token objects like:
        [
            {
                "id_type": TokenTypes.APPMETRICA_DEVICE_ID,
                "id_values": ["123456789", "42"]
            },
            {
                "id_type": TokenTypes.IOS_IFA,
                "id_values": ["8A690667-6204-4A6A-9B38-85DE016....."]
            },
            {
                "id_type": TokenTypes.ANDROID_PUSH_TOKEN,
                "id_values": ["eFfxdO7uCMw:APA91bF1tN3X3BAbiJXsQhk-..."]
            }
        ]
    
    ios_message - push message for ios devices
    android_message - push message for android devices:
        {
            "silent": false,
            "content": {
                "title": "string",
                "text": "string",
                "sound": "disable",
                "data": "string"
            }
        }
  4. To check status of push call check_status method:

    status = api.check_status(transfer_id)

List of available groups

  1. Create API instance:

    from appmetrica.push.api import PushAPI
    
    api = PushAPI(application_id, access_token)
  2. Get list of groups

    group_id = api.get_groups()

Export tokens

  1. Create API instance:

    from appmetrica.export.api import ExportAPI
    
    api = ExportAPI(application_id, access_token)
  2. Call push_tokens method with necessary fields:

    data = api.export_push_tokens('token', 'ios_ifa', 'google_aid')

Export devices

  1. Create API instance:

    from appmetrica.export.api import ExportAPI
    
    api = ExportAPI(application_id, access_token)
  2. Call push_tokens method with necessary fields:

    date_till = datetime.now()
    date_from = date_till - timedelta(days=7)
    
    data = api.export_installations('ios_ifv', date_from=date_from, date_till=date_till)

Publish a release on PyPi

Install twine globally:

pip install twine
  1. Don’t forget to bump the package version:

    __version__ = '1.0.3'
  2. Build the release:

    python setup.py sdist bdist_wheel
  3. Publish the release on PyPi:

    twine upload dist/*

Changelog

1.0.2 (2019-01-09)

  • Increased request timeout to 30 seconds

1.0.1 (2018-12-17)

  • Replace deprecated send method to send-batch

1.0.0 (2017-12-14)

  • Initial release

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

appmetrica-1.0.4.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

appmetrica-1.0.4-py2.py3-none-any.whl (8.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file appmetrica-1.0.4.tar.gz.

File metadata

  • Download URL: appmetrica-1.0.4.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.5

File hashes

Hashes for appmetrica-1.0.4.tar.gz
Algorithm Hash digest
SHA256 030d771b6cd329d96e397c26fc3d657f825e122630c412563fe1f46fb1ba5d36
MD5 ef22a989e73ed7f6f8a8176c96db56bc
BLAKE2b-256 bd50e464c53e0b63df6ce0acfcbd8deac8f8bf102c9338d8c7f4284b98c70571

See more details on using hashes here.

File details

Details for the file appmetrica-1.0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: appmetrica-1.0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.4

File hashes

Hashes for appmetrica-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 af40980e4642c7367e937f2e580cea6a77d7a573cd0cee81d8c5a49d68ae1e8d
MD5 5584d9390f4c167f7aa190698bc57e31
BLAKE2b-256 d458f9885160233ec27392c7483d58cbaa6ea86c7222b57c54f12ddea24dec5d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page