Skip to content

ahl389/times-books

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TimesBooks

This is a lightweight ruby API client for the New York Times' Books API.

Installation

Add this line to your application's Gemfile:

gem 'times_books'

And then execute:

$ bundle install

Usage

Getting Started

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

Connecting to the API

Create a new client (probably in a model):

client = TimesBooks::Client.new()

Making Queries

For more details, you can explore the API over here: https://developer.nytimes.com/books_api.json

Get List By Name

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 Lists by Best Seller

Search for a Best Seller List that contains a book with a certain author, title, or publisher.

client.searchLists(author, title, publisher)
Get All Lists

Gets an overview of all the different best seller lists. Please note this endpoint will not return any book results.

client.getLists()
Get Published Lists By Date

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 Reviews

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)

Contributing

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.

License

The gem is available as open source under the terms of the MIT License.

About

Ruby client for Times Books API

Resources

License

Stars

Watchers

Forks

Packages

No packages published