Fetching Alexa data

NB: This approach doesn't work anymore. The endpoint simply returns "Ok", even for URLs which aren't assigned.

There is a free API (though I haven't been able to find any documentation for it anywhere).

http://data.alexa.com/data?cli=10&url=%YOUR_URL%

You can also query for more data the following way:

http://data.alexa.com/data?cli=10&dat=snbamz&url=%YOUR_URL%

All the letters in dat are the ones that determine which info you get. This dat string is the one I've been able to find which seems to have more options. Also, cli changes the output completely, this option makes it return an XML with quite a lot of information.

EDIT: This API is the one used by the Alexa toolbar.


A simple function to get the alexa rank

function alexa_rank($url){
    $xml = simplexml_load_file("http://data.alexa.com/data?cli=10&url=".$url);
    if(isset($xml->SD)):
        return $xml->SD->REACH->attributes();
    endif;
}

Works pretty well and free ;)

Tags:

Php

Api

Alexa