The most basic form of API interaction: Querying a specific URL and getting
its parsed result. If the response is empty, the function returns an empty
tibble(), and if there are date-time variables
present in the response, they are converted to POSIXct
via
lubridate::ymd_hms()
or to Date
via lubridate::as_date()
if the
variable only contains date information.
Value
The parsed content of the API response.
An empty tibble() if the response is an empty
JSON
array.
Details
See the official API reference for a detailed overview of available methods. Most methods of potential interest for data collection have dedicated functions in this package.
Examples
# A simple request to a direct URL
trakt_get("https://api.trakt.tv/shows/breaking-bad")
#> $title
#> [1] "Breaking Bad"
#>
#> $year
#> [1] 2008
#>
#> $ids
#> $ids$trakt
#> [1] 1388
#>
#> $ids$slug
#> [1] "breaking-bad"
#>
#> $ids$tvdb
#> [1] 81189
#>
#> $ids$imdb
#> [1] "tt0903747"
#>
#> $ids$tmdb
#> [1] 1396
#>
#> $ids$tvrage
#> NULL
#>
#>
# Optionally be lazy about URL specification by dropping the hostname:
trakt_get("shows/game-of-thrones")
#> $title
#> [1] "Game of Thrones"
#>
#> $year
#> [1] 2011
#>
#> $ids
#> $ids$trakt
#> [1] 1390
#>
#> $ids$slug
#> [1] "game-of-thrones"
#>
#> $ids$tvdb
#> [1] 121361
#>
#> $ids$imdb
#> [1] "tt0944947"
#>
#> $ids$tmdb
#> [1] 1399
#>
#> $ids$tvrage
#> NULL
#>
#>