knitr::opts_chunk$set( collapse = TRUE, comment = "#>", message = FALSE, warning = FALSE, error = FALSE, out.width = "100%" )
library(tRakt)
That's all you need to to for basic things. If you're planning a larger project with lots and lots of data retrieval, you might want to create your own API app on trakt.tv and use trakt_credentials()
to set your client id
.
Using a text query:
search_query("Game of Thrones", type = "show")
Search by explicit ID:
search_id("121361", id_type = "tvdb", type = "show")
Or via whatever's popular(ish):
Another scenario would be that you're not necessarily interested in some specific media item, but rather a collection of items that fulfill certain criteria, like being popular on trakt.tv and maybe being from a specific period or genre and whatnot. While you can also filter search_query
by other criteria, it's maybe more useful to filter, let's say, the most watched movies of the past week by the release year of the movie.
The 5 most popular shows:
shows_popular(limit = 5)
The 10 most watched (during the past year) movies from 1990-2000:
library(dplyr) movies_watched(period = "yearly", years = c(1990, 2000)) %>% select(watcher_count, title, year)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.