Get Website Rank using Alexa API

1 min read

Alexa Internet, Inc. is an American web traffic analysis company based in San Francisco. It is a subsidiary of Amazon. collects data on Internet browsing behavior and transmits them to the Alexa website, where they are stored and analyzed.

Full Source Code for Getting Website Rank using Alexa API


  font-weight: bold;

  font-size: 24px;
  margin-left: 5px;
  border-radius: 5px;
  background: #2bbb0f no-repeat 5px 50%;
  background: #E41F26 no-repeat 5px 50%;

<form action="" method="get">
  Website URL :<input type="text" name="url">
  <input type="submit" value="Get Alexa Rank">


    $url = $_GET['url'];

    $api_url = "".$url;
    $response = file_get_contents($api_url);
    $xml = simple_load_string($response);

    $global_rank = $xml->SD->POPULARITY['TEXT'];
    $country_name = $xml->SD->COUNTRY['NAME'];
    $country_rank = $xml->SD->COUNTRY['RANK'];
    $delta = $xml->SD->RANK['DELTA'];

<h4 class="title">Global Rank</h4>
  <span class="ranking"><?php echo $global_rank;?></span>
  <?php if($delta<0){ $class="minus";}else{ $class="plus";}?>
  <span class="<?php echo $class;?>">
    <?php echo substr($delta,1);?>

<h4 class="title">Rank in <?php echo $country_name;?></h4>
<p class="ranking"><?php echo $country_rank;?></p>


Recommended For You

About the Author: Ritesh Ghimire