LoginSignup
7
3

More than 5 years have passed since last update.

iTunes ConnectとGoogle Playのダウンロード数を取得するための準備

Last updated at Posted at 2017-02-26

はじめに

iOS, Androidの両アプリをリリースしているとDownload数のレポートなど、互いのサイトを行ったり来たりするのはめんどうなことが多いと思います。
今回、iTunes ConnectとGoogle Playのダウンロード数をCSVにまとめるスクリプトを書くことになったので共有したいと思っています。

iTunes Connectからダウンロード数を取得

iTunes Connectからダウンロード数を取得するのに Autoingestion を使用します。

公式Documentによると..

Reporter は、Java ベースのコマンドラインツールで、「売上とトレンド」および「支払と財務報告」のレポートをダウンロードするために使用します。Autoingestion は Reporter 以前にリリースされたツールで、同様の機能を持ちます。新しい機能や拡張された機能は Reporter でのみ利用可能であるため、今後は Reporter を使用することが推奨されます。

さっそく、Reporter をダウンロードしましょう。

解凍すると

  • Reporter.jar
  • Reporter.properties

の2つのファイルができると思います。 Reporter.propertiesに2箇所、 Apple ID, Passwordを指定して保存しましょう。

UserId=...
Password=...

Mode=Normal

SalesUrl=https://reportingitc-reporter.apple.com/reportservice/sales/v1
FinanceUrl=https://reportingitc-reporter.apple.com/reportservice/finance/v1

Mode=Normal は初期設定と違いますが、 出力が見やすくなるのでこちらにしています。どちらでもいいと思います..。これでReporterを使う準備はできました。

統計レポートを取得するコマンドの書式は以下のようになっています。

$ java -jar Reporter.jar p=[properties file] Sales.getReport [vendor number], [report type], [report subtype], [date type], [date]

[vendor number] というものを取得する必要がありますので、下記コマンドを叩いて取得しましょう。

getVendors について
このコマンドは、レポートをダウンロードできるベンダー番号の一覧を返します。
Normal モードでは、各ベンダーが独立した行に表示されます。

java -jar Reporter.jar p=Reporter.properties Sales.getVendors
12345678
23456789

どちらかが正しいもの (人によっては1個だったり複数だったり)するので、アプリに応じた適切なvendorを選択してください。

では、レポートを取得していきます。

getReport について
このコマンドは、売上レポートをダウンロードするために使用します。

java -jar Reporter.jar p=Reporter.properties Sales.getReport 12345678, Sales, Summary, Daily, 20170225

詳しくはこちら

正しくコマンドを叩くと、以下のように出力されます。

java -jar Reporter.jar p=Reporter.properties Sales.getReport 12345678, Sales, Summary, Daily, 20170220
Successfully downloaded S_D_12345678_20170220.txt.gz

Google Playからダウンロード数を取得

lib/gsutil.zip を解答して、 /Applications/ に移動させてください。

.bash_profile に以下の行を追加します。

export PATH=/Applications/gsutil:$PATH

設定を読み込みます。

$ source ~/.bash_profile

(Macの人は pip install gsutil でいけます。 これ以降の作業は共通です。)

gsutilで認証させるために、下記コマンドを叩いてください。

$ gsutil config

Please navigate your browser to the following URL:
https://accounts.google.com/o/oauth2/......
In your browser you should see a page that requests you to authorize access to Google Cloud Platform APIs and Services on your behalf. After you approve, an authorization code will be displayed.

Enter the authorization code:


Please navigate your browser to https://cloud.google.com/console#/project,
then find the project you will use, and copy the Project ID string from the
second column. Older projects do not have Project ID strings. For such projects,
 click the project and then copy the Project Number listed under that project.

What is your project-id? YOUR_PROJECT_ID

Boto config file "/Users/RINDO/.boto" created. If you need to use a
proxy to access the Internet please see the instructions in that file.

https://accounts.google.com/o/oauth2/... の部分を、ブラウザで開いて認証を行った後、コードを打ち込みましょう。

また What is your project-id? の部分には、 Google Developer Consoleで確認した自分のprojectのIDを貼り付けましょう。 ( Firebaseで作成している場合は、Firebaseのproject idかな?未確認です。)

次に bucket idを確認しましょう。 pubsite_prod_rev_ で始まるものがBucket IDです。

これで、 gsutilも使えるようになりました。試しに、以下のコマンドを叩いてみましょう。

gsutil ls gs://pubsite_prod_rev_12345.../stats/installs/

CSVをダウンロードするときは、以下のコマンドでいけます。

gsutil cp -r PATH LOCAL_PATH
  • PATHには、 gsutil ls で表示した、ほしいファイルのパスを指定
  • LOCAL_PATHには、ローカルのパスを指定しましょう。 ~/Desktop とかでいいんじゃないでしょうか。

次は、レポートをまとめるコードを書きたいと思います!

7
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
3