knitr::opts_chunk$set( collapse = TRUE, comment = "#>", echo = FALSE ) library(tRakt) library(kableExtra) library(purrr) library(dplyr) library(stringr)
api <- system.file("api-methods.yml", package = "tRakt") |> yaml::read_yaml() api <- api |> map_dfr(~ { map_dfr(.x, as_tibble, .id = "Method") }, .id = "Section") pkg_funs <- getNamespaceExports("tRakt") |> str_subset("trakt_get|build_trakt_url", negate = TRUE) unmentioned <- pkg_funs[!(pkg_funs %in% str_remove_all(api$implementation, pattern = "\\(\\)"))] format_api_table <- function(xdf) { xdf |> mutate( endpoint = glue::glue("<a href = '{url}'>{endpoint}</a>"), # Section = stringr::str_to_title(Section), # Section = cell_spec(Section, bold = TRUE), Method = str_to_title(Method), Method = str_replace_all(Method, "^Id\\s", "ID "), #implementation = if_else(is.na(implementation), "N/A", implementation), implementation = if_else( implementation == "none", "", glue::glue("<code>{implementation}</code>") ), authentication = if_else( !is.na(authentication), cell_spec("Required", bold = TRUE, color = "white", background = "red"), cell_spec("Optional", bold = FALSE, color = "white", background = "green") ), ) |> select( -url, Endpoint = endpoint, Auth = authentication, Implementation = implementation ) } print_api_table <- function(xdf) { xdf |> kbl(escape = FALSE) |> kable_styling( position = "center", bootstrap_options = c("striped", "hover"), full_width = TRUE ) |> column_spec(column = 3, width_min = "20%") }
This is a reference list of API methods available, their endpoint URLs (with user-specified parameters indiciated by a :
prefix) and a link to their respective implementation in this package, if applicable.
Authenticated methods (there's only a few) are indicated as such.
Note that not all available methods are listed here, especially those geared towards interactive apps – I highly doubt that people will want to post (or update) comments through this package.
api |> filter(Section == "search") |> select(-Section) |> format_api_table() |> print_api_table()
api |> filter(Section == "movies") |> select(-Section) |> format_api_table() |> print_api_table()
api |> filter(Section == "shows") |> select(-Section) |> format_api_table() |> print_api_table()
api |> filter(Section == "seasons") |> select(-Section) |> format_api_table() |> print_api_table()
api |> filter(Section == "episodes") |> select(-Section) |> format_api_table() |> print_api_table()
api |> filter(Section == "people") |> select(-Section) |> format_api_table() |> print_api_table()
api |> filter(Section == "users") |> select(-Section) |> format_api_table() |> print_api_table()
api |> filter(Section == "comments") |> select(-Section) |> format_api_table() |> print_api_table()
api |> filter(Section == "lists") |> select(-Section) |> format_api_table() |> print_api_table()
These endpoints are used to check filter arguments. The output is cached in tidied up format as package datasets.
api |> filter(Section %in% c( "certifications", "countries", "genres", "languages", "networks" )) |> format_api_table() |> select(-Auth) |> print_api_table()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.