When Will the App Store Cross One Billion?

With Apple giving away great loot ($10,000 iTunes Gift Card, an iPod touch, a Time Capsule, and a MacBook Pro) when they reach the One Billionth Download (American, not British “billion”), what I want to know is when I need to start feverishly downloading apps or filling out the no-purchase-necessary entry form. Consequently I’ve written this little widget that uses Apple’s own statistics to estimate the crossover point. [Now that we’re past, I’ve locked the “prediction” down to the last posted Apple statistic before the crossover. -Rob]

Apple only seems to be updating their statistics once per hour, so there’s no point in refreshing very often. Of course their predicted selling rate changes as well, so don’t come crying to me when you don’t when the Ten Grand!

Is it Accurate?

No.

These things never are, but they’re fun. Here’s a chart someone else made up that shows how the rate changes often. That would throw off the prediction pretty badly. I could try to do some kind of running average, but simply put, I don’t think I will.

Chart courtesy "Sendai" on #macosx

Include On Your Page

You can put this on your own page (it’s only meaningful this week) by adding the following javascript to your page:<script src="http://blog.iharder.net/wp-content/uploads/2009/04/appstore.js.php"></script>
If you want to style it at all, here’s an example of the generated HTML:

How It’s Calculated

Looking at the HTML source for Apple’s countdown page, I examined the javascript file at http://images.apple.com/global/scripts/downloadcounter.js and a sort of data file that was referenced at http://images.apple.com/autopush/us/itunes/includes/countdown.txt. The countdown.txt file was interesting. I’m guessing there’s a cron job that does some calculations and dumps this text file out once per hour. It looks like this:

13-APR-2009 20:00:00|949783866|300134

The script file itself was a bit obfuscated but not badly. The function dataRequestDidFinishLoading, called in response to an AJAX fetch, told the whole story:

I followed a similar logic stream, but because my browser (and yours, hopefully) tries to guard against cross-site scripting, or possibly because I wasn’t smart enough to get around it, I couldn’t make a similar AJAX call to Apple’s countdown.txt file since it comes from a different domain than where my script was loaded. Instead I have the ugly hack of having PHP dynamically generate the JavaScript file on the fly. The PHP server makes a call to Apple’s countdown.txt file and hard-wires it into the script as it’s downloaded.