<commit_before>Ralexa
======

Ruby client for Amazon Alexa APIs.

These include [Alexa Top Sites][1] and [Alexa Web Information Service][2].

HTTP transport thanks to `Net::HTTP`,
with a little help from [addressable][3].

XML parsing courtesy of [Nokogiri][4].

Thorough test coverage provided by `MiniTest::Spec`.

[1]: http://aws.amazon.com/awis/
[2]: http://aws.amazon.com/alexatopsites/
[3]: https://github.com/sporkmonger/addressable
[4]: http://nokogiri.org/


Installation
------------

```sh
# with bundler
echo 'gem "ralexa"' >> Gemfile
bundle

# or just the gem
gem install ralexa
```


Usage Examples
--------------

```ruby

# grab a Ralexa::Session instance to hold your credentials.
session = Ralexa.session("aws_access_key_id", "aws_secret_access_key")

# all countries
countries = session.top_sites.list_countries
p countries.map(&:name)

# global top 250 sites
global = session.top_sites.global(250)

# per-country top sites
first_by_country = {}
countries.each do |c|
  first_by_country[c.name] = session.top_sites.country(c.code, 1).first.url
end

# individual country lookup
puts "Top Ten Australian Sites"
session.top_sites.country("AU", 10).each do |s|
  puts "#{s.url} (#{s.page_views} pageviews)"
end

puts "bam!"
```


Status
------

<table>
  <tr>
    <th>Service</th>
    <th>Action</th>
    <th>ResponseGroup</th>
    <th>Supported</th>
  </tr>
  <tr>
    <td rowspan="3">Alexa Top Sites</th>
    <td>TopSites</th>
    <td>Global</th>
    <td>Yes</th>
  </tr>
  <tr>
    <td></th>
    <td>Country</th>
    <td>Yes</th>
  </tr>
  <tr>
    <td></th>
    <td>ListCountries</th>
    <td>Yes</th>
  </tr>
  <tr>
    <td rowspan="5">Alexa Web Information Services</th>
    <td>UrlInfo</th>
    <td>*</th>
    <td>Send a pull request!</th>
  </tr>
  <tr>
    <td>TrafficHistory</th>
    <td>*</th>
    <td>Send a pull request!</th>
  </tr>
  <tr>
    <td>CategoryBrowse</th>
    <td>*</th>
    <td>Send a pull request!</th>
  </tr>
  <tr>
    <td>CategoryListings</th>
    <td>*</th>
    <td>Send a pull request!</th>
  </tr>
  <tr>
    <td>SitesLinkingIn</th>
    <td>*</th>
    <td>Send a pull request!</th>
  </tr>
</table>


Contributing
------------

1. Fork it<commit_msg>update README with rank usage<commit_after>Ralexa
======

Ruby client for Amazon Alexa APIs.

These include [Alexa Top Sites][1] and [Alexa Web Information Service][2].

HTTP transport thanks to `Net::HTTP`,
with a little help from [addressable][3].

XML parsing courtesy of [Nokogiri][4].

Thorough test coverage provided by `MiniTest::Spec`.

[1]: http://aws.amazon.com/awis/
[2]: http://aws.amazon.com/alexatopsites/
[3]: https://github.com/sporkmonger/addressable
[4]: http://nokogiri.org/


Installation
------------

```sh
# with bundler
echo 'gem "ralexa"' >> Gemfile
bundle

# or just the gem
gem install ralexa
```


Usage Examples
--------------

```ruby

# grab a Ralexa::Session instance to hold your credentials.
session = Ralexa.session("aws_access_key_id", "aws_secret_access_key")

# all countries
countries = session.top_sites.list_countries
p countries.map(&:name)

# global top 250 sites
global = session.top_sites.global(250)

# per-country top sites
first_by_country = {}
countries.each do |c|
  first_by_country[c.name] = session.top_sites.country(c.code, 1).first.url
end

# individual country lookup
puts "Top Ten Australian Sites"
session.top_sites.country("AU", 10).each do |s|
  puts "#{s.url} (#{s.page_views} pageviews)"
end

# rank of an individual site
puts "Rank of Flippa.com"
puts session.url_info.rank("http://flippa.com")

puts "bam!"
```


Status
------

<table>
  <tr>
    <th>Service</th>
    <th>Action</th>
    <th>ResponseGroup</th>
    <th>Supported</th>
  </tr>
  <tr>
    <td rowspan="3">Alexa Top Sites</td>
    <td>TopSites</td>
    <td>Global</td>
    <td>Yes</td>
  </tr>
  <tr>
    <td></td>
    <td>Country</td>
    <td>Yes</td>
  </tr>
  <tr>
    <td></td>
    <td>ListCountries</td>
    <td>Yes</td>
  </tr>
  <tr>
    <td rowspan="6">Alexa Web Information Services</td>
    <td>UrlInfo</td>
    <td>Rank<td>
    <td>Yes</td>
  </tr>
  <tr>
    <td>TrafficHistory</td>
    <td>*</td>
    <td>Send a pull request!</td>
  </tr>
  <tr>
    <td>CategoryBrowse</td>
    <td>*</td>
    <td>Send a pull request!</td>
  </tr>
  <tr>
    <td>CategoryListings</td>
    <td>*</td>
    <td>Send a pull request!</td>
  </tr>
  <tr>
    <td>SitesLinkingIn</td>
    <td>*</td>
    <td>Send a pull request!</td>
  </tr>
</table>


Contributing
------------

1. Fork it
{'fraction_non_alphanumeric': 0.1946725860155383, 'fraction_numerical': 0.008879023307436182, 'mean_word_length': 3.1568265682656826, 'pattern_counts': {'":': 0, '<': 163, '<?xml version=': 0, '>': 167, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '581570', 'n_tokens_mistral': 1835, 'n_tokens_neox': 1766, 'n_words': 403}