Access The Etsy API in Ruby

Long ago, my wife found a love for Etsy. When I recently discovered their public API, I figured that it was meant to be that I begin working on a clean implementation of the Etsy API in Ruby. So I did.

I'm releasing the first version to the public tonight that includes support for retrieving users, their shops, and associated listings.

Installation

A simple gem installation is all you need:

sudo gem install etsy

If you prefer to bleed:

sudo gem install reagent-etsy --source=http://gems.github.com

Usage

Once installed, set up your API key and you're ready to go:

require 'rubygems'
require 'etsy'

Etsy.api_key = 'snipsnap'

At the time of this post, all API calls are read-only so that's all you need to do. Let's get started by finding a user's shop:

user = Etsy.user('littletjane') # => #<Etsy::User:0x1057624 ... >
user.seller?                    # => true
user.shop.name                  # => "littletjane"

A shop can have multiple listings:

user.shop.listings  # => [#<Etsy::Listing:0x1001788 ... >, ... ]

listing = user.shop.listings.first

listing.title       # => "hanging with the bad boys matchbox"
listing.description # => "standard size matchbox, approx. 1.5 x 2 ... "

Each listing, in turn, can have one or more images:

image = listing.images.first

image.small_square # => "http://ny-image2.etsy.com/il_25x25.67765346.jpg"
image.large        # => "http://ny-image2.etsy.com/il_430xN.67765346.jpg"

For more information and usage examples, check out the documentation on Rubyforge. If you have feature requests or comments, open an issue on Github or send me an email.

blog comments powered by Disqus