Skip to contents

build_trakt_url assembles a trakt.tv API URL from different arguments. The result should be fine for use with trakt_get, since that's what this function was created for.

Usage

build_trakt_url(..., validate = FALSE)

Arguments

...

Unnamed arguments will be concatenated with / as separators to form the path of the API URL, e.g. the arguments movies, tron-legacy-2012 and releases will be concatenated to movies/tron-legacy-2012/releases. Additional named arguments will be used as query parameters, usually extended = "full" or others.

validate

logical(1) [TRUE]: Whether to check the URL via httr::HEAD request.

Value

A URL: character of length 1. If validate = TRUE, also a message including the HTTP status code return by a HEAD request.

Note

Please be aware that the result of this function is not verified to be a working trakt.tv API URL unless validate = TRUE, in which case a HEAD request is performed that does not actually receive any data, but from its returned status code the validity of the URL can be inferred.

See also

Other utility functions: pad_episode()

Examples

build_trakt_url("shows", "breaking-bad", extended = "full")
#> [1] "https://api.trakt.tv/shows/breaking-bad?extended=full"
build_trakt_url("shows", "popular", page = 3, limit = 5)
#> [1] "https://api.trakt.tv/shows/popular?page=3&limit=5"

# Path can also be partially assembled already
build_trakt_url("users/jemus42", "ratings")
#> [1] "https://api.trakt.tv/users/jemus42/ratings"

# Validate a URL works
build_trakt_url("shows", "popular", page = 1, limit = 5, validate = TRUE)
#> [1] "https://api.trakt.tv/shows/popular?page=1&limit=5"