GithubHelp home page GithubHelp logo

vacuum's Introduction

Vacuum

Build Status

Vacuum is a fast, light-weight Ruby wrapper to the Amazon Product Advertising API.

vacuum

Usage

Setup

Set up a request:

req = Vacuum.new

The locale defaults to the US. To use another locale, instantiate with its two-letter country code:

req = Vacuum.new('GB')

Configure the request credentials:

req.configure(
    aws_access_key_id:     'key',
    aws_secret_access_key: 'secret',
    associate_tag:         'tag'
)

Alternatively, set the key and secret as environment variables globally:

export AWS_ACCESS_KEY_ID=key
export AWS_SECRET_ACCESS_KEY=secret

You will still need to set a distinct associate tag for each locale:

req.associate_tag = 'tag'

Request

Set up your parameters and make a request:

params = {
  'SearchIndex' => 'Books',
  'Keywords'    => 'Architecture'
}
res = req.item_search(query: params)

The above executes an item search operation. The names of available methods derive from the operations listed in the API docs and include browse_node_lookup, cart_add, cart_clear, cart_create, cart_get, cart_modify, item_lookup, item_search, and similarity_lookup.

Vacuum uses Excon as HTTP client. Check the Excon API for ways to tweak your request:

res = req.item_search(query: params, persistent: true)

Response

The quickest way to consume a response is to parse it into a Ruby hash:

res.to_h

Vacuum uses MultiXml, which will work with a number of popular XML libraries. If working in MRI, you may want to use Ox.

You can also pass the response body into your own parser for some custom XML heavy-lifting:

MyParser.new(res.body)

vacuum's People

Contributors

hakanensari avatar ezkl avatar gerhard avatar bruno-campos avatar laszpio avatar cambridgemike avatar christophebelpaire avatar snoblenet avatar aisensiy avatar ryanmarshall avatar

Watchers

David Tompkins avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.