getBestSellerCategories: Get information from the NY Times best sellers lists

View source: R/NYTimes.R

getBestSellerCategoriesR Documentation

Get information from the NY Times best sellers lists

Description

getBestSellerCategories allows you to retrieve the list of available categories in the New York Times best-seller lists. getBestSellers retrieves the data for a particular category.

Usage

getBestSellerCategories(key = getOption("NYTimesAPI")["Best Sellers"])
getBestSellers(list = "Paperback-Books", n = 10, date = NA, offset = 0, 
                 key = getOption("NYTimesAPI")["Best Sellers"])

Arguments

key

character string, the API key that authorizes the request

list

the name of the category or best-seller list of interest

n

the number of items to retrieve

offset

the offset into the result set at which to start. This is an integer multiple of 20

date

the date for which the best sellers list is sought. This can be approximate and the NY Times services looks at that date and after for the "nearest" list. This can be a string in the form of YYYY-MM-DD or a POSIXt object or Date object.

Value

getBestSellerCategories returns a character vector. These include "Hardcover Fiction" "Hardcover Nonfiction" "Hardcover Advice" "Paperback Nonfiction" "Paperback Advice" "Trade Fiction Paperback" "Picture Books" "Chapter Books" "Paperback Books" "Series Books" "Mass Market Paperback".

getBestSellers returns a data frame with 11 columns named rank, list_name, bestsellers_date, published_date, weeks_on_list, rank_last_week, asterisk, dagger, book_details, isbns, reviews.

Author(s)

Duncan Temple Lang

References

http://developer.nytimes.com/docs/best_sellers_api

Examples

if("NYTimesAPI" %in% names(options()) && "Best Sellers" %in% names(options("NYTimes"))) {

   categories = getBestSellerCategories()
   sapply(categories, getBestSellers, n = 30)
}

omegahat/RNYTimes documentation built on Nov. 29, 2023, 12:39 a.m.