• Stars
    star
    167
  • Rank 225,974 (Top 5 %)
  • Language
    Ruby
  • Created over 14 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📚 📦 Amazon Simple INterface - Support for ItemLookup, SimilarityLookup, Search, BrowseNode and Cart Operations

Infos

Build Status

ASIN is a simple, extensible wrapper for parts of the REST-API of Amazon Product Advertising API (aka Associates Web Service aka Amazon E-Commerce Service).

For more information on the REST calls, have a look at the whole Amazon E-Commerce-API.

Have a look at the RDOC for this project, if you like browsing some docs.

The gem runs smoothly with Rails and is tested against multiple rubies. See .travis.yml for details.

Upgrading from Version 1.x

Version 2 removes all the SimpleXXX classes in favor of Hashie::Rash.

The old API is available if you require ASIN::Adapter:

require 'asin'
require 'asin/adapter'

It's also a good starting point for looking into writing your own asin-adapter.

Installation

gem install asin

or in your Gemfile:

gem 'asin'

Configuration

Rails style initializer (config/initializers/asin.rb):

ASIN::Configuration.configure do |config|
  config.secret        = 'your-secret'
  config.key           = 'your-key'
  config.associate_tag = 'your-tag'
end

Have a look at ASIN::Configuration class for all the details.

Usage

ASIN is designed as a module, so you can include it into any object you like:

# require and include
require 'asin'
include ASIN::Client

# lookup an ASIN
lookup '1430218150'

# lookup multiple items by ASIN
lookup ['1430218150','1934356549']

But you can also use the instance method to get a proxy-object:

# just require
require 'asin'

# create an ASIN client
client = ASIN::Client.instance

# lookup an item with the amazon standard identification number (asin)
items = client.lookup '1430218150'

# have a look at the title of the item
items.first.item_attributes.title
# => Learn Objective-C on the Mac (Learn Series)

# search for any kind of stuff on amazon with keywords
items = client.search_keywords 'Learn', 'Objective-C'
items.first.item_attributes.title
# => "Learn Objective-C on the Mac (Learn Series)"

# search for any kind of stuff on amazon with custom parameters
items = client.search :Keywords => 'Learn Objective-C', :SearchIndex => :Books
items.first.item_attributes.title
# => "Learn Objective-C on the Mac (Learn Series)"

# search for similar items like the one you already have
items = client.similar '1430218150'
items.first.item_attributes.title
# => "Beginning iOS 7 Development: Exploring the iOS SDK"

There is an additional set of methods to support AWS cart operations:

client = ASIN::Client.instance

# create a cart with an item
cart = client.create_cart({:asin => '1430218150', :quantity => 1})
cart.cart_items.cart_item
# => [<#Hashie::Rash ASIN="1430218150" CartItemId="U3G241HVLLB8N6" ... >]

# clear everything from the cart
cart = client.clear_cart(cart)
cart.cart_items.cart_item
# => []

# update items in the cart
cart = client.update_items(cart, {:cart_item_id => cart.items.first.CartItemId, :action => :SaveForLater}, {:cart_item_id # => cart.items.first.CartItemId, :quantity => 7})
cart.saved_for_later_items.saved_for_later_item
# => [<#Hashie::Rash ASIN="1430218150" CartItemId="U3G241HVLLB8N6" ... >]

It's also possible to access browse nodes:

client = ASIN::Client.instance

# create a cart with an item
node = client.browse_node('17', :ResponseGroup => :TopSellers)
node.first.browse_node_id
# => '163357'
node.first.name
# => 'Literature & Fiction'

Confiture

ASIN uses Confiture as a Configuration gem. See the Confiture documentation for different configuration styles.

License

"THE (extended) BEER-WARE LICENSE" (Revision 42.0815): phoet contributed to this project.

As long as you retain this notice you can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me some beers in return.

More Repositories

1

freemium

🆓 👷 example of how to use heroku cedar stack to run a free application with web, worker and clock processes
Ruby
37
star
2

memo-it

📥 📤 simple yet clever memoization helper with parameter support
Ruby
30
star
3

computering

🎹 💨 Pretends you can type really fast
Ruby
23
star
4

partially_useful

📑 👀 Helps identifying partials in verbose HTML source code.
Ruby
23
star
5

whitelabel

✒️📛 whitelabel your application
Ruby
18
star
6

buildr-examples

🔧 🔩 examples for using buildr
Ruby
13
star
7

active_service

Transactional services for Rails
Ruby
12
star
8

rails_redis_cache

rails cache store implementation with redis
Ruby
12
star
9

karotz

ruby bindings for the karotz rest api
Ruby
12
star
10

TravisSeeEye

Build Monitor for Travis-CI
Ruby
11
star
11

confiture

Easy configuration for your Gem.
Ruby
10
star
12

idgas

I dont give a shit - Is a helper for handling nil in deep data structures.
Ruby
8
star
13

savon_handsoap_shootout

An article on popular SOAP-Clients savon and handsoap
Ruby
8
star
14

mongodb_examples

Examples of Mongo Ruby Driver, Mongoid and MongoMapper running on MongoHQ.
Ruby
5
star
15

rebuil

A Regular Expression Builder
Ruby
4
star
16

zazicki

reload middleware code in development
Ruby
4
star
17

dzone_android

DZone Mobile for Android
Java
3
star
18

ruby-java-jruby-rjb

ruby in java, java in ruby, jruby or ruby java bridge
Java
3
star
19

sinastrano

sinastrano - deploy your capistrano application over the web
Ruby
3
star
20

dzone

dzone iphone client
C
2
star
21

which_ruby

helper for checking the current ruby runtime/engine/version
Ruby
2
star
22

tomcat-logging

example for configuring tomcat logging
Java
2
star
23

rubygolfhh

RubyGolfHH
Ruby
2
star
24

file_cache

Simple caching-utility for persisting arbitrary data in a file.
Ruby
1
star
25

saaspose

Ruby bindings to Saaspose REST API
Ruby
1
star
26

shortcuts

all kinds of ruby shortcuts
Ruby
1
star
27

savon_nosql_example

savon_nosql_example
Ruby
1
star
28

asin_web

Showcase for the ASIN gem
Ruby
1
star
29

gdcr11

conway's game of life
Ruby
1
star
30

faselcharts

backup of jörgs best fasel cites
CSS
1
star
31

purr_captcha

purr_captcha
Ruby
1
star
32

basement

basement, my personal homepage aka phoet.de
Ruby
1
star
33

nibble

🐰 📃 OpenKarotz ruby bindings
Ruby
1
star
34

freibierrufler

FREIBIER!
Ruby
1
star
35

tippr

tolingobl hilfstool
Ruby
1
star
36

dzone_api

rails project providing a clean restfull api to dzone
Ruby
1
star