Welcome to the desert of the real

A quick and dirty getting started guide to the Sierra APIs

Created by Justin Hopkins

APIs Drop April 28, 2014

Yeah, like a month ago...

Details ahead

This is your last chance. After this, there is no turning back. You take the blue pill - the story ends, you wake up in your bed and believe whatever you want to believe. You take the red pill - you stay in Wonderland and I show you how deep the rabbit-hole goes.

Good news

It's not that deep.

Log into the admin application

i.e. https://galahad.searchmobius.org/sierra/admin

This menu item is your friend

If you don't have it, you'll need to add the permission "Api Consumer Administration (1052)"

Add a client/key

Enter client information

Verify via email

receive your key and set up your client secret

Are we there yet?


You can't decode the matrix

require 'oauth2'

baseurl = "https://galahad.searchmobius.org/"

client = OAuth2::Client.new('API_KEY_HERE', 'CLIENT_SECRET_HERE', :site => "#{baseurl}", :token_url => '/iii/sierra-api/v1/token')

token = client.client_credentials.get_token

beforeDate = Time.now.utc.iso8601.to_s
afterDate = (Time.now - (2*7*24*60*60)).utc.iso8601.to_s

response = token.get('iii/sierra-api/v1/bibs?createdDate=[' + afterDate + ',' + beforeDate + ']&deleted=false&suppressed=false')

# results is a Hash, containing one key/value: "entries"
results = response.parsed
# entries is an array, each value is a Hash.
entries = results["entries"]

# API returns results sorted by id, which tends to result in newer stuff last
# We want newer stuff first
entries = entries.sort_by!{|value| value.fetch("createdDate", "")}.reverse

puts "

New titles added in the last two weeks

" entries.each do |value| recordUrl = baseurl + "record=b" + value.fetch("id", "").to_s createDate = Time.iso8601(value.fetch("createdDate", "")).to_s title = value.fetch("title", "") puts <<-eos


eos end

"I don't even see the code."

The output

Yes, it's ugly.

But it works!

I think we're done here.

Slides: http://bit.ly/sierra_api