Skip to contents

Search for a show or movie with a keyword (e.g. "Breaking Bad") and receive basic info of the first search result. It's main use is to retrieve the IDs or proper show/movie title for further use, as well as receiving a quick overview of a show/movie.

Usage

search_query(
  query,
  type = "show",
  n_results = 1L,
  extended = c("min", "full"),
  years = NULL,
  genres = NULL,
  languages = NULL,
  countries = NULL,
  runtimes = NULL,
  ratings = NULL,
  certifications = NULL,
  networks = NULL,
  status = NULL
)

search_id(
  id,
  id_type = c("trakt", "imdb", "tmdb", "tvdb"),
  type = "show",
  n_results = 1L,
  extended = c("min", "full")
)

Source

search_query() wraps endpoint search/:type?query=.

search_id() wraps endpoint search/:id_type/:id?type=.

Arguments

query

character(1): Search string for titles and descriptions. For search_query() other fields are searched depending on the type of media. See the API docs for a full reference.

type

character(1) ["show"]: The type of data you're looking for. One of show, movie, episode, person or list or a character vector with those elements, e.g. c("show", "movie"). Note that not every combination is reasonably combinable, e.g. c("movie", "list"). Use separate function calls in that case.

n_results

integer(1) [1]: How many results to return.

extended

character(1): Either "min" (API default) or "full". The latter returns more variables and should generally only be used if required. See vignette("finding-things") for more details.

years

character | integer: 4-digit year (2010) or range, e.g. "2010-2020". Can also be an integer vector of length two which will be coerced appropriately, e.g. c(2010, 2020).

genres

character(n): Genre slug(s). See trakt_genres for a table of genres. Multiple values are allowed and will be concatenated.

languages

character(n): Two-letter language code(s). Also see trakt_languages for available languages (code and name).

countries

character(n): Two-letter country code(s). See trakt_countries.

runtimes

character | integer: Integer range in minutes, e.g. 30-90. Can also be an integer vector of length two which will be coerced appropriately.

ratings

character | integer: Integer range between 0 and 100. Can also be an integer vector of length two which will be coerced appropriately. Note that user-supplied ratings are in the range of 1 to 10, yet the ratings on the site itself are scaled to the range of 1 to 100.

certifications

character(n): Certification(s) like pg-13. Multiple values are allowed. Use trakt_certifications for reference. Note that there are different certifications for shows and movies.

networks

character(n): (Shows only) Network name like HBO. See trakt_networks for a list of known networks.

status

character(n): (Shows only) The status of the shows. One of "returning series", "in production", "planned", "canceled", or "ended".

id

character(1): The id used for the search, e.g. 14701 for a Trakt ID.

id_type

character(1) ["trakt"]: The type of id. One of trakt, imdb, tmdb, tvdb.

Value

A tibble containing n_results results. Variable type is equivalent to the value of the type argument, and variable score indicates the search match, where 1000 is a perfect match. If no results are found, the tibble has 0 rows. If more than one type is specified, e.g. c("movie", "show"), there will be n_results results per type.

Details

The amount of information returned is equal to *_summary API methods and in turn depends on the value of extended. See also the API reference here for which fields of the item metadata are searched by default.

Examples

# A show
search_query("Breaking Bad", type = "show", n_results = 3)
#> # A tibble: 3 × 9
#>   type  score title           year trakt  slug                tvdb   imdb  tmdb 
#>   <chr> <dbl> <chr>          <int> <chr>  <chr>               <chr>  <chr> <chr>
#> 1 show  1303. GLOW            2017 116959 glow                324835 tt57… 70573
#> 2 show  1262. The Langoliers  1995 164166 the-langoliers-1995 211741 tt01… 18197
#> 3 show  1247. Danny Phantom   2004 2295   danny-phantom       78443  tt03… 2309 
if (FALSE) {
# A show by its trakt id, and now with more information
search_id(1388, "trakt", type = "show", extended = "full")

# A person
search_query("J. K. Simmons", type = "person", extended = "full")

# A movie or a show, two of each
search_query("Tron", type = c("movie", "show"), n_results = 2)
}