Skip to content

Latest commit

 

History

History
158 lines (108 loc) · 3.91 KB

README.md

File metadata and controls

158 lines (108 loc) · 3.91 KB

Alexa Web Information Service

Ruby client for AWIS

Installation

gem install alexa

Usage

All success response objects contain response_id method.

Url Info

client = Alexa::Client.new(access_key_id: "key", secret_access_key: "secret")
url_info = client.url_info(url: "site.com")

Returns object that contains methods:

  • rank
  • data_url
  • site_title
  • site_description
  • language_locale
  • language_encoding
  • links_in_count
  • keywords
  • related_links
  • speed_median_load_time
  • speed_percentile
  • rank_by_country
  • rank_by_city
  • usage_statistics
  • categories

You can specify options:

  • url - address to be measured
  • response_group - which data to include in response (i.e. ["rank", "contact_info"]) - defaults to all available

See: Docs for valid groups.

Sites Linking In

client = Alexa::Client.new(access_key_id: "key", secret_access_key: "secret")
sites_linking_in = client.sites_linking_in(url: "site.com")

Returns object that contains method:

  • sites

You can specify options:

  • url - address to be measured
  • count - how many results to retrieve - defaults to max value that is 20
  • start - offset of results - defaults to 0

Traffic History

client = Alexa::Client.new(access_key_id: "key", secret_access_key: "secret")
traffic_history = client.traffic_history(url: "site.com")

Returns object that contains methods:

  • site
  • range
  • start
  • data

You can specify options:

  • url - address to be measured
  • range - how many days to retrieve - defaults to max value 31
  • start - start date (i.e. "20120120", 4.days.ago) - defaults to range number days ago

Category Browse

client = Alexa::Client.new(access_key_id: "key", secret_access_key: "secret")
category_browse = client.category_browse(path: "Top/Games/Card_Games")

Returns object that contains methods:

  • categories
  • language_categories
  • related_categories
  • letter_bars

You can specify options:

  • path - category to be measured (i.e. "Top/Games/Card_Games") - valid paths can be found on dmoz
  • response_group - any of: categories, related_categories, language_categories, letter_bars - defaults to all
  • descriptions - should response include descriptions (i.e. false) - defaults to true

Category Listings

client = Alexa::Client.new(access_key_id: "key", secret_access_key: "secret")
category_listings = client.category_listings(path: "Top/Games/Card_Games")

Returns object that contains methods:

  • count
  • recursive_count
  • listings

You can specify options:

  • path - category to be measured (i.e. "Top/Games/Card_Games") - valid paths can be found on dmoz
  • sort_by - sort results by one of: popularity, title, average_review - defaults to popularity
  • recursive - should result include subcategories (i.e. false)- defaults to true
  • count - how many results to retrieve - defaults to max value, that is 20
  • start - offset of results - defaults to 0
  • descriptions - should response include descriptions (i.e. false) - defaults to true

Caveats

Status Code

You can retrieve Alexa status code calling status_code method.

It happens (so far in TrafficHistory) that Alexa returns response 200 with AlexaError status.

Parsers

Alexa is using multi_xml to parse XML documents. Tested with:

  • rexml
  • nokogiri
  • libxml

Currently alexa will not work with ox gem

Contributors

Continuous Integration

Build Status

Copyright

Copyright (c) Wojciech Wnętrzak. See LICENSE for details.