Giter VIP home page Giter VIP logo

itunesanalyticsapp's Introduction

Itunes Analytics App Data Fetched

Python data fetcher from https://analytics.itunes.apple.com

Preamble

Despite of anouncement of a new Apple Analytics API at WWDC 2018 in June'18 (see the video), it's not yet available even in the end of August'18. Hence inspired by the node.js' module itunesconnectanalytics, for my current task, I decided to make a python module to fetch the data from Itunes Analytics App.

Logic

The module is made to download csv data files for a given time and metric. It's based on selenium library and uses Chrome WebDriver to emulate real user interacting with the Itunes Analytics App by launching a headless chrome browser (you can easility specify another browser in case it's required).

Steps:

  1. Login to https://appstoreconnect.apple.com using your credentials from credentials.json

credentials.json structure:

{"user":"[email protected]", "pass":"YOUR_ITUNES_PASS"}
  1. Access https://analytics.itunes.apple.com with specified metric and time frame

List of metrics:

{"impressions": "impressionsTotalUnique", 
 "views": "pageViewUnique", 
 "downloads": "units", 
 "installs": "installs", 
 "sessions": "sessions", 
 "ad": "activeDevices", 
 "crash": "crashes", 
 "purchases": "iap", 
 "bookings": "sales", 
 "pu": "payingUsers"}
  1. Download the csv data file from the page on step 2 by emulating a click on the "download" icon

Example

As an example, let's fetch daily installs during July'18 for the application with the itunes ID APPID

Load required modules

import json
import os
from itunes_app_analytics import (Params, 
                                  Login, 
                                  DataFetcher,
                                  browser)

Read the appstoreconnect.apple.com (itunes) credentials

PATH = os.path.dirname(__file__)
credentials = json.load(open(os.path.join(PATH, 'credentials.json')))

Specify the metrics, time frame and the output folder

# list of metrics
param = Params()
# input parameters
metric = 'downloads'
tframe = 'month'
tview = 'day'
date = '201807'

# output dir
dir_out = '/tmp'

Login into https://appstoreconnect.apple.com

_ = Login(credentials['user'], credentials['pass'])

Launch a data fetcher "instance" and set the output folder

fetcher = DataFetcher
# set the output folder
fetcher.output_dir(download_dir = dir_out)

Download the data and close the browser

downloader = fetcher.download
downloader(APPID, param.measure[metric], param.interval[tframe], param.zoom[tview], date)
browser.close()

Done! We've just automated data extraction from Itunes Analytics.

Requirements

  • Chrome 62+
  • Chrome WebDriver (it's provided with the module in the folder browser)
  • python3.6 (it'll most likely work on 2.7, but it wasn't tested)

Modules (use requiremenets.txt):

  • json >= 2.0.9
  • selenium >= 3.13.0

itunesanalyticsapp's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.