iOSアプリのダウンロード数は、Appleから提供されいてるJavaのツールを使うことでiTunes Connect (以下 iTC) から自動取得できます。 今回は、それをRubyで行う方法をご紹介します。
手順
事前準備
iTCへの接続には、以下の情報が必要です。
- iTCへログイン可能な、id / password
- 該当ユーザには、Report権限が必要
- VENDOR ID
VENDOR_IDは、iTCの下記画面から確認できます。
[売上とトレンド] > [トップコンテンツ] > [レポート]
以下赤枠に表示されている数値が、VENDOR_IDです。
Rubyでの実装
gemを作成されている方がいらっしゃいましたので、こちらを利用します。
GitHub - siuying/itunes-auto-ingestion: A simple port of Apple itunes Autoingestion tool to ruby.
gemインストール
gem 'itunes_ingestion', '~> 0.3.0'
requireに追加
require "itunes_ingestion"
ログインする
user_id = "aaaa@aaa.com" password = "password" vendor_id = 12345678 fetcher = ITunesIngestion::Fetcher.new(user_id, password, vendor_id)
Dailyデータを取得する
option ={ report_date: "20160801" } report_data = fetcher.fetch(option) reports = ITunesIngestion::SalesReportParser.parse(report_data)
Weeklyのデータを取得する。report_dateは週末(日曜日)の日付を指定必要です。
option ={ report_date: "20160807", date_type: "Weekly" } report_data = fetcher.fetch(option) reports = ITunesIngestion::SalesReportParser.parse(report_data)
取得データの見方
以下のようなデータが配列で取得できます。
{:provider=>"APPLE", :country=>"US", :sku=>"xxxxxxxxxxxxxxxx", :developer=>"xxxxxxxxxxxxxxxx", :title=>"xxxxxxxxxxxxxxxxxxxxxxxx", :version=>"1.1.0", :product_type_id=>"7", :units=>10, :developer_proceeds=>0.0, :begin_date=>Fri, 05 Aug 2016, :end_date=>Fri, 05 Aug 2016, :currency=>"USD", :country_code=>"US", :currency_of_proceeds=>"USD", :apple_id=> 123456789, :customer_price=>0.0, :promo_code=>"", :parent_id=>"", :subscription=>"", :period=>" "}
product_type_idを以下を意味しているので、単純に新規ダウンロード数だけカウントしたい場合は、「 product_type_id = 1」のレコードだけを抽出すればカウント可能です。
- 1 : Free or paid app iPhone and iPod touch (iOS)
- 3 : Redownload of iPhone-only, or iOS and tvOS app (excluding iPad-only)
- 7 : Update iPhone and iPod touch (iOS)
他にも区分がありますので、詳細はマニュアル参照ください。
http://www.apple.com/itunesnews/docs/AppStoreReportingInstructions.pdf