Project

rowling

0.0
No commit activity in last 3 years
No release in over 3 years
A simple Ruby wrapper for accessing USA Today bestseller data.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
~> 1.3.0
~> 10.0

Runtime

~> 2.3.6
~> 0.13.3
~> 1.3.2
 Project Readme

Rowling

A Ruby wrapper for the USA Today Bestsellers API.

Usage

First, you'll need an API key, which you can get here. Then, you can set up a client:

client = Rowling::Client.new(api_key: YOUR_KEY)

##Books Search for books included in bestseller lists:

search_params = { author: "J.K. Rowling",
                  title: "Deathly Hallows"
                }

books = client.search_books(search_params)

You can view the search parameters here.

This returns an array of Book objects:

books.first.title = "Harry Potter and the Deathly Hallows"
books.first.author = "J.K. Rowling, art by Mary GrandPre"
books.first.title_api_url = "/Titles/9780545010221"

Books from search only have title, author and api url. For more detailed information, you can find books directly by ISBN:

book = client.find_book_by_isbn("9780545010221")

Attributes will include:

title, title_api_url, author, class, description, book_list_appearances, highest_rank, ranks

##Booklists You can search for book lists by year, month and date. All parameters are optional and without parameters it will retrive the most recent list.

client.get_booklists(year: 2015, month: 2)

##Other Requests

# returns available book classes (fiction vs. nonfiction)
client.get_classes

# returns available book categories
client.get_categories

# returns dates that bestseller lists were published on (can be filtered by using 
# parameters of month and year, without parameters returns all dates since Oct. 1993)
client.get_dates(year: 2015, month: 3)

##Options

If you don't want the responses parsed for you, set up your client with "raw" set to true. The default is false.

client = Rowling::Client.new(api_key: YOUR_API_KEY, raw: true)

If you would like the client to pause and retry requests when you hit a rate limit, set up your client with "retries" set to the number of times you would like it to retry requests. The default is 0.

client = Rowling::Client.new(api_key: YOUR_API_KEY, retries: 2)

###Why is it called Rowling? She holds the record for longest #1 USA Today Bestselling Book, with Harry Potter and Sorcerer's Stone topping the list for 31 weeks in 1999. So that's pretty cool.