Project

giddy

0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Ruby client for Getty API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

>= 0.11.0
>= 1.8.0
= 2.7.2
 Project Readme

Giddy

Giddy is a Ruby gem for interacting with the {Getty Images Connect API}[https://github.com/gettyimages/connect].

Installation

gem install giddy

Configuration

To set up the authorization configuration for the system (different than your per-user credentials), use:

Giddy.setup do |config|
  config.system_id = "12345"
  config.system_password = "alongpassword"
end

Usage

First, create a client object with a username and password

client = Giddy::Client.new("ausername", "apassword")

Searching:

images = client.search(:query => "puppy")

# or, with pagination
images = client.search(:query => "kitty", :start => 21, :limit => 20)

# or, by image id (returns only one):
image = client.search(:image_id => "110740425")

Get an images details:

image = client.search(:image_id => "110740425")
puts image
puts image.artist

Download request:

puts image.download_largest

To get the available sizes, and then the URL of the download for the smallest:

image = client.search(:image_id => "136094606")
# image.sizes is ordered by file size, smallest to largest
smallest = image.sizes.first
puts image.download(smallest).url_attachment

It's also possible to cache session information so that you don't have to reauthenticate on each client creation. For instance:

client = Giddy::Client.new("username", "password")
# next line happens automatically if a session doesn't exist or if a session goes stale
# let's force it, just to get some tokens
client.create_session

# these can be stored somewhere (memcache, etc)
token = client.token
secure_token = client.secure_token

# create a new client with old tokens so a new session doesn't have to be initialized
# if the tokens have gone stale, a new session will be created
otherclient = Giddy::Client.new("username", "password", token, secure_token)
puts otherclient.search(:image_id => "110740425")