Downloading App Sales Reports with Pythonista

Apple's web interface for viewing sales reports in iTunes Connect looks pretty nice, but one big problem with it is that you don't see how much money you've actually made – it only shows the number of downloads. The CSV files contain all the data, but it's still pretty hard to figure out the actual revenue, because all the numbers are in different currencies.

Now, there are a lot of solutions to this problem already – you might use AppViz on the Mac, AppFigures as a web service, or my own little open source project AppSales on iOS. But I still thought it might be fun to write a little report downloader script that runs in Pythonista. In its current form, it simply downloads all the available daily reports, gets the currency conversion rates from Yahoo!, and prints a short summary for each report, with the revenue converted to your preferred currency.

By itself, this might not be all that exciting, but I imagine that it could be quite useful as a starting point for doing different kinds of data analysis that might not be (easily) possible with the standard tools.

Here's what you need:

  • The actual script: https://gist.github.com/omz/6108848 1
  • Your iTunes Connect username and password (the script will ask for your login and save it in the keychain)
  • Your "vendor ID" – this is the number that's shown next to your name in the iTunes Connect "Sales and Trends" section, something like 80123456

The script uses the same web API as Apple's official "auto-ingest" command-line tool. It sometimes returns weird errors when you try to download too often in a short period of time, but waiting a few minutes usually helps.

If you want to write your own data analysis functions, you might want to have a look at the Sales and Trends Guide (PDF), which contains all the details about the format of the report files (in particular, see appendix E for a list of product type identifiers).


  1. You can download Gists more easily with this script: http://omz-software.com/pythonista/forums/discussion/5/sharing-code-on-github/p1