Vacuum is a thin Ruby wrapper to various Amazon Web Services (AWS) APIs.
gem install vacuum
Amazon Product Advertising API
Vacuum knows the Amazon Product Advertising API inside out.
Set up a request:
req = Vacuum.new :product_advertising req.configure do |config| config.key = 'key' config.secret = 'secret' config.tag = 'tag' end
Build and run a search:
req.build operation: 'ItemSearch', search_index: 'Books', keywords: 'Deleuze' res = req.get res.valid? or raise res.code p res.body
Or run the same search less verbosely:
res = req.search :books, 'Deleuze' p res.body
The response wraps a Nokogiri document:
And lets you drop down to any node:
res.find('Item') do |item| p item end
Browse more examples here.
Amazon Marketplace Web Services API
The wrapper to the Amazon Marketplace Web Services API is a work-in-progress.
Set up a request to the Products API:
req = Vacuum.new(:mws_products) do |config| config.locale = 'US' config.key = 'key' config.secret = 'secret' config.marketplace = 'marketplace' config.seller = 'seller' end
Get the lowest offers for a single ASIN:
req.build 'Action' => 'GetLowestOfferListingsForASIN', 'ASINList.ASIN.1' => '0231081596' offers = req.get.find 'GetLowestOfferListingsForASINResult'
I will at some point throw in some syntactic sugar for common operations.
Other AWS APIs
Vacuum should work with all AWS libraries, including EC2, S3, IAM, SimpleDB, SQS, SNS, SES, and ELB. Most of these already have popular Ruby implementations. If you need to implement one using Vacuum, please fork and send a pull request when done.
HTTP Client Adapters
You can use any of the alternative adapters Faraday supports:
req.connection do |builder| builder.adapter :em_synchrony end
Workers queuing to crawl AWS.