This is a lightweight ruby API client for the New York Times' Books API.
Add this line to your application's Gemfile:
gem 'times_books'
And then execute:
$ bundle install
In your rails app add a file to your config/initializers directory called times_books.rb:
TimesBooks.configure(
api_key: 'YOUR API KEY'
)
If you need an API key, you can grab one here: https://developer.nytimes.com/signup
Create a new client (probably in a model):
client = TimesBooks::Client.new()
For more details, you can explore the API over here: https://developer.nytimes.com/books_api.json
Return the most recent published version of an individual Times' Best Seller List by name (i.e. hardcover-fiction). You can get the full name list with getLists(). Please note this endpoint can accomodate queries with whole slew of parameters but the gem is currently only set up to grab by name. Contributions to this gem could include setting up some of these other parameters.
client.getListByName(name)
Search for a Best Seller List that contains a book with a certain author, title, or publisher.
client.searchLists(author, title, publisher)
Gets an overview of all the different best seller lists. Please note this endpoint will not return any book results.
client.getLists()
Returns a complete set of published lists, including the books on those lists, for provided date. Date should be in YYYY-MM-DD format.
client.getListsByDate(date)
Search for a book review by the book's title, author, or isbn. 10 or 13 digit ISBNs will work.
client.searchReviews(isbn, title, author)
I welcome contributions from anyone who wants to expand on this gem and include more queries. Bug reports and pull requests are welcome on GitHub at https://github.com/ahl389/times_books.
The gem is available as open source under the terms of the MIT License.