Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Ruby wrapper to the Amazon Product Advertising API

This branch is 214 commits behind hakanensari:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
examples
lib
spec
.gitignore
.travis.yml
CHANGELOG.md
Gemfile
LICENSE
README.md
Rakefile
vacuum.gemspec
vacuum.png

README.md

Vacuum

vacuum

travis

Vacuum is a Nokogiri-backed Ruby wrapper to the Amazon Product Advertising API.

 Installation

Add to your Gemfile:

gem 'vacuum'

 Configuration

Set up a locale:

Vacuum.configure :uk do |c|
  c.key    = 'a key'
  c.secret = 'a secret'
  c.tag    = 'a tag'
end

If you do not specify a locale, Vacuum will default to the US:

Vacuum.configure do |c|
  c.key    = 'a key'
  c.secret = 'a secret'
  c.tag    = 'a tag'
end

 The Request

Create a request for the above locale:

req = Vacuum.new(:uk)

Again, if you don't specify a locale, the request will default to the US:

req = Vacuum.new

Search for something:

req << { :operation    => 'ItemSearch',
         :search_index => 'All',
         :keywords     => 'George Orwell' }
res = request.get

The following shorthand accomplishes the same search:

res = req.search('George Orwell')

Customise your request:

res = req.search('Books', :response_group => 'ItemAttributes',
                          :power          => 'George Orwell'

For all available methods and syntax, read here.

The Response

Check if the response is valid:

res.valid?

While it sounds quirky, a valid response may contain errors. Check for those as well:

res.has_errors?

Consume the entire response as a hash:

res.to_hash

Preferably, drop down to a particular node and consume the relevant bits and pieces you need:

res.each('Item') do |item|
  # item['ASIN']
end
Something went wrong with that request. Please try again.