Léon Brocard


Net::Amazon::AWIS - Use the Amazon Alexa Web Information Service


  use Net::Amazon::AWIS;
  my $awis = Net::Amazon::AWIS->new($subscription_id);
  my $data1= $awis->url_info(url => "http://use.perl.org/");
  my $data2 = $awis->web_map(url => "http://use.perl.org");
  my @results = $awis->crawl(url => "http://use.perl.org");


The Net::Amazon::AWIS module allows you to use the Amazon Alexa Web Information Service.

The Alexa Web Information Service (AWIS) provides developers with programmatic access to the information Alexa Internet (www.alexa.com) collects from its Web Crawl, which currently encompasses more than 100 terabytes of data from over 4 billion Web pages. Developers and Web site owners can use AWIS as a platform for finding answers to difficult and interesting problems on the Web, and incorporating them into their Web applications.

In order to access the Alexa Web Information Service, you will need an Amazon Web Services Subscription ID. See http://www.amazon.com/gp/aws/landing.html

Registered developers have free access to the Alexa Web Information Service during its beta period, but it is limited to 10,000 requests per subscription ID per day.

There are some limitations, so be sure to read the The Amazon Alexa Web Information Service FAQ.


The interface follows. Most of this documentation was copied from the API reference. Upon errors, an exception is thrown.


The constructor method creates a new Net::Amazon::AWIS object. You must pass in an Amazon Web Services Access Key ID and a Secret Access Key. See http://www.amazon.com/gp/aws/landing.html:

  my $sq = Net::Amazon::AWIS->new($aws_access_key_id, $secret_access_key);


The url_info method provides information about URLs. Examples of this information includes data on how popular a site is, and sites that are related.

You pass in a URL and get back a hash full of information. This includes the Alexa three month average traffic rank for the given site, the median load time and percent of known sites that are slower, whether the site is likely to contain adult content, the content language code and character-encoding, which dmoz.org categories the site is in, and related sites:

  my $data = $awis->url_info(url => "http://use.perl.org/");
  print "Rank:       " . $data->{rank}                 . "\n";
  print "Load time:  " . $data->{median_load_time}     . "\n";
  print "%Load time: " . $data->{percentile_load_time} . "\n";
  print "Likely to contain adult content\n" if $data->{adult_content};
  print "Encoding:   " . $data->{encoding}             . "\n";
  print "Locale:     " . $data->{locale}               . "\n";

  foreach my $cat (@{$data->{categories}}) {
    my $path  = $cat->{path};
    my $title = $cat->{title};
    print "dmoz.org: $path / $title\n";

  foreach my $related (@{$data->{related}}) {
    my $canonical  = $related->{canonical};
    my $url        = $related->{url};
    my $relevance  = $related->{relevance};
    my $title      = $related->{title};
    print "Related: $url / $title ($relevance)\n";


The web_map method returns a list of web sites linking to a given web site. Within each domain linking into the web site, only a single link - the one with the highest page-level traffic - is returned. The data is updated once every two months.

  my $data = $awis->web_map(url => "http://use.perl.org");
  my @links_in  = $data->{links_in};


The crawl method returns information about a specific URL as provided by the most recent Alexa Web Crawls. Information about the last few times the site URL was crawled is returned. Crawl takes the URL and a count.

Information per crawl include: URL, IP address, date of the crawl (as a DateTime object), status code, page length, content type and language. In addition, a list of other URLs is included (like "rel" URLs), as is the list of images and links found.

  my @results = $awis->crawl(url => "http://use.perl.org", count => 10);
  foreach my $result (@results) {
    print "URL: "          . $result->{url} . "\n";
    print "IP: "           . $result->{ip} . "\n";
    print "Date: "         . $result->{date} . "\n";
    print "Code: "         . $result->{code} . "\n";
    print "Length: "       . $result->{length} . "\n";
    print "Content type: " . $result->{content_type} . "\n";
    print "Language: "     . $result->{language} . "\n";

    foreach my $url (@{$result->{other_urls})) {
      print "Other URL: $url\n";

    foreach my $images (@{$result->{images})) {
      print "Image: $image\n";

    foreach my $link (@{$result->{links})) {
      my $name = $link->{name};
      my $uri  = $link->{uri};
      print "Link: $name -> $uri\n";


This module currently does not support "Browse Category" or "Historical Traffic" searches.

Please report any bugs or feature requests to bug-<Net-Amazon-AWIS@rt.cpan.org>, or through the web interface at http://rt.cpan.org.


Leon Brocard acme@astray.com


Copyright (c) 2005-8, Leon Brocard acme@astray.com. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.