PHP Script to get Alexa Rank

Alexa traffic rank is a value given to any website by alexa based on it’s traffic. A lower traffic rank means higher traffic volume to a website. Alexa is providing an paid API to access it database. But there is a way to do this for free. To get this data in XML format use following URL<>

To parse this XML file either you can use regular expression match or use inbuilt php5 function simplexml_load_file. here i am doing this with simplexml_load_file

PHP code to get Alexa Rank

$xml = simplexml_load_file(''.$url);
echo $web." has Alexa Rank ".$rank;

To get other info like alexa backlinks, website load time, dmoz listing etc, use similar method to parse XML

Eg: To get alexa backlink


Alexa Rank checker Demo

Liked It? Get Free updates in your Email

Delivered by feedburner

10 thoughts on “PHP Script to get Alexa Rank

  1. abcd

    woww its working. Thank you so much

  2. Odie

    I use wordpress, where I had to put the above code?

    1. gvzcvx

      you put the code on your website LOL

  3. Rhoula

    I’ve made a little script that lets you add the Alexa Rank to a Mysql database.

    The script is nothing big. I was wishing to share it in exchange of small donations. The reason I’m asking for donations is because I’m having a little trouble taking care of my household and I’m hoping to go 100% freelancing.

    Thank you for being understanding.

    Have a wonderful day.

  4. Ahmed

    Boooom. WOrking Script Bro Thank You Soo Much.

  5. akash

    super its working..

  6. clasificados cuba

    Great post, I made an imrpoved version of this and I like to share.

    private function getAlexaRank($domain_name = ‘’)
    $xml = simplexml_load_file(‘’ . $domain_name);

    $rank = isset($xml->SD[1]->POPULARITY) ? $xml->SD[1]->POPULARITY->attributes()->TEXT : 0;
    //$web = (string)$xml->SD[0]->attributes()->HOST;
    $reach = isset($xml->SD[1]->POPULARITY) ? $xml->SD[1]->REACH->attributes()->RANK : 0;
    $delta = isset($xml->SD[1]->POPULARITY) ? $xml->SD[1]->RANK->attributes()->DELTA : 0;

    return [‘rank’ => $rank, ‘reach’ => $reach, ‘delta’ => $delta];

    So just call it by var_dump($this->getAlexaRank(‘’));


  7. thalhah

    Hi, still can use in 2017?

    1. Sunny Post author

      Yes its still working


Leave a Reply

Your email address will not be published. Required fields are marked *