Skip to main content

A Python package for the Unity Analytics Raw Data Export REST API

Project description

unityrde

unityrde (Unity raw data export) is a Python 3 package for pulling raw data from the Unity Analytics REST API. See the Unity documentation for more information on how this works.

Installation

python -m pip install unityrde

Quickstart guide

Firstly, create a UnityDataImporter object and include your Unity project id and your API key:

from unityrawdataexport import *

upid = "aa43ae0a-a7a7-4016-ae96-e253bb126aa8"
key = "166291ff148b2878375a8e54aebb1549"
udi = UnityDataImporter(upid, key)

To pull data from the API you need to first either create a new data export, or use a data export that has been created previously. For the latter case, you need to get the export_id. The list_data_exports method can be used to identify previously created data exports:

# Get a json of the metadata of all data exports
exports = udi.list_data_exports()

# get the id of the most recent export
export_id = exports[0]['id']

You can then use the get_data_export method to get a json of the data from this export:

data = udi.get_data_export(export_id)

If you need to create a new export, you can run create_export. Make sure when setting the parameters that you include a startDate, endDate and dataset. For help on parameters, see the Unity documentation.

params = {
  'startDate': '2019-09-01',
  'endDate': '2019-09-30',
  'dataset': 'appStart'
}

udi.create_export(params)

This will create a new export_id, which is associated with the class through the export_id attribute. The export will usually take a minute or two to be created. You can check its status by looking at the export metadata:

print(udi.get_data_export(output='metadata')['status'])

Note that it was not necessary to specify the export_id this time. Once the status is completed, you can get a json of the data:

data = udi.get_data_export()

Alternatively, you can do all this in one step using the create_and_get_export method:

data = udi.create_and_get_export(params)

pandas and longer exports

For convenience, there are a couple of methods in the package that allow you to output pandas dataframes. Firstly, any json data file you produce from the previous step can be converted using the convert_to_pandas function

df = convert_to_pandas(data)

Secondly, the make_long_df method can be used to export more than 31 days of data at once. It does this by creating multiple exports and appending them together into a single pandas DataFrame.

params['startDate'] = '2019-08-01'
params['endDate'] = '2019-10-14'
df = udi.make_long_df(params)

Maintenance

I made this package in a professional context. I am no longer able to test the functionality of the package, because I do not have access to a Unity Analytics account. I will fix obvious errors where I can, but if the Unity API changes in such a way that breaks this package, I will not be able to repair it.

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

unityrde-0.0.2.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

unityrde-0.0.2-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file unityrde-0.0.2.tar.gz.

File metadata

  • Download URL: unityrde-0.0.2.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for unityrde-0.0.2.tar.gz
Algorithm Hash digest
SHA256 af62b3d89a21bbda39c917d65f39ca2ae6f2d21e4972532abce2decfb2899b4d
MD5 4619f71f799aaf3b1e8549e631c7a6cd
BLAKE2b-256 993caea997f764ee8a01cca998de087ca6222d9cac740f6d3f45fe20e6505786

See more details on using hashes here.

File details

Details for the file unityrde-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: unityrde-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4

File hashes

Hashes for unityrde-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 094c34aa40e5925e2211e4419fce4590a2e3caec8ca840f2c4647909b71eac24
MD5 4f612be86811e9f1b1353a211bfe9ddf
BLAKE2b-256 3494a877a05e6647f50d453c8f39a9ad3db9b8899e93c24dbefe24a0945a4a42

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