Home > Utility > When Will the App Store Cross One Billion?

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?


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

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:

<div id="___appstore" style="position:relative;border:solid black 1px;
  width: 300px; font-family: Verdana; text-align:center;
  -webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
  padding: 5px; margin: 5px auto">
  iPhone App Store Predicted Crossover</div>
  <div style="font-size: 16pt" id="___estDate">Monday, April 20th 2009</div>
  <div style="font-size: 16pt" id="___estTime">7:27:07 PM PDT</div>
  <div style="font-size:6pt;color:#555">
    Last Apple statistic:
    <span id="___source">13-APR-2009 19:00:00|949483732|299885</span>

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:

dataRequestDidFinishLoading: function(n) {
    var j = n.responseText.split("|"),
    if (j.length === 3) {
        m = j[0].split(" ");
        c = m[1];
        date = m[0].split("-");
        this.setRate(parseInt(j[2]) / 3600000);
        k = date[0];
        f = date[1];
        i = date[2];
        a = Date.parse(f + " " + k + ", " + i + " " + c + " GMT-0700");
        d = new Date(a + 3600000);
        l = d.getTime() - a + 1000;
        this._nextUpdateTimeout = setTimeout(this.loadData.bind(this), l);
        b = new Date();
        this._lastReferenceTime = b.getTime();
        e = this._lastReferenceTime - a;
        h = Math.floor(parseInt(j[1]) + e * (this._rate));

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.

Enjoy! Let me know if you discover any errors in my math.

Categories: Utility Tags:
  1. April 20th, 2009 at 22:53 | #1

    Nearly there!

  2. October 14th, 2014 at 08:10 | #2

    Pretty! This was an incredibly wonderful article. Many thanks for
    supplying this info.

  3. November 14th, 2014 at 14:23 | #3

    You could definitely see your skills within the article you write.
    The world hopes for more passionate writers
    like you who are not afraid to mention how they believe.

    At all times go after your heart.

  1. No trackbacks yet.