trakt

A trakt.tv API wrapper in R.

https://github.com/jemus42/trakt

Science Score: 26.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (20.2%) to scientific vocabulary

Keywords

r r-package rstats trakt trakt-api trakttv
Last synced: 10 months ago · JSON representation

Repository

A trakt.tv API wrapper in R.

Basic Info
Statistics
  • Stars: 23
  • Watchers: 2
  • Forks: 3
  • Open Issues: 4
  • Releases: 18
Topics
r r-package rstats trakt trakt-api trakttv
Created almost 12 years ago · Last pushed 10 months ago
Metadata Files
Readme Changelog License Code of conduct Codemeta

README.Rmd

---
output: github_document
editor_options: 
  chunk_output_type: console
---



```{r setup, include = FALSE}
knitr::opts_chunk$set(
  cache = TRUE,
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%",
  message = FALSE, warning = FALSE, error = FALSE
)
```

# tRakt tRakt website


[![R-CMD-check](https://github.com/jemus42/tRakt/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jemus42/tRakt/actions/workflows/R-CMD-check.yaml)
[![CRAN status](https://www.r-pkg.org/badges/version/tRakt)](https://cran.r-project.org/package=tRakt)
[![GitHub release](https://img.shields.io/github/release/jemus42/tRakt.svg?logo=GitHub)](https://github.com/jemus42/tRakt/releases)
[![Project Status: WIP – Initial development is in progress, but there has not yet been a stable, usable release suitable for the public.](https://www.repostatus.org/badges/latest/wip.svg)](https://www.repostatus.org/#wip)
[![Codecov test coverage](https://codecov.io/gh/jemus42/tRakt/graph/badge.svg)](https://app.codecov.io/gh/jemus42/tRakt)


`tRakt` lets you retrieve data from [trakt.tv](https://trakt.tv/), a site similar to [IMDb](https://imdb.com) with a wider focus, yet smaller user base. The site also enables media-center integration, so you can automatically sync your collection and watch progress, as well as scrobble playback and ratings via [Plex](https://www.plex.tv/), [Kodi](https://kodi.tv/) and streaming services like Netflix and AppleTV+.  
And, most importantly, [trakt.tv has a publicly available API](https://trakt.docs.apiary.io), which makes this package possible and allows you to collect all that nice data people have contributed.

Please note that while this package is *basically* an API-client, it is a little more opinionated and might deliver results that do not exactly match the data delivered by the API. The primary motivation for this package is to retrieve data that is easily processable for data analysis and display, which is why it tries hard to coerce most data into tabular form instead of using nested lists, which is what the direct translation of the API results would look like.

## Installation

Get it from GitHub:

```r
if (!("pak" %in% installed.packages())) {
  install.packages("pak")
}
pak::pak("jemus42/tRakt")

```

...or from [r-universe](https://jemus42.r-universe.dev/tRakt):

```r
install.packages("tRakt", repos = "https://jemus42.r-universe.dev")
```

## Usage

```{r}
library(tRakt)
library(dplyr) # for convenience
```

Search for a specific show from 2013 (and not the US adaptation) and get basic info:

```{r}
show_info <- search_query("Utopia", year = "2013", type = "show")
glimpse(show_info)
```

We'll use the `$trakt` ID for subsequent requests.

Get season information for the show using its trakt ID:

```{r}
seasons_summary(show_info$trakt, extended = "full") |>
  glimpse()
```

Get episode data for the first season, this time using the show's URL slug:

```{r}
seasons_episodes(show_info$trakt, seasons = 1, extended = "full") |>
  glimpse()
```

You cann also get episode data for all seasons, but note that episodes will be included as a list-column and need further unpacking:

```{r}
seasons_summary(show_info$trakt, episodes = TRUE, extended = "full") |>
  pull(episodes) |>
  bind_rows() |>
  glimpse()
```

Or alternatively, get the [trending shows](https://trakt.tv/shows/trending):

```{r}
shows_trending()
```

Maybe you just want to know how long it would take you to binge through these shows:

```{r}
shows_trending(extended = "full") |>
  transmute(
    show = glue::glue("{title} ({year})"),
    runtime_hms = hms::hms(minutes = runtime),
    aired_episodes = aired_episodes,
    runtime_aired = hms::hms(minutes = runtime * aired_episodes)
  ) |>
  knitr::kable(
    col.names = c("Show", "Episode Runtime", "Aired Episodes", "Total Runtime (aired)")
  )
```

Please note though that episode runtime data may be inaccurate. In my experience, recent shows have fairly accurate runtime data, which is often not the case for older shows.

## Credentials

The API requires at least a `client id` for the API calls.  
Loading the package (or calling its functions via `tRakt::` wil automatically set the app's credentials for authentication, but for extended use you should set your own credentials via environment variables in your `.Renviron` like this:

```sh
# tRakt
trakt_client_id=12fc1de7[...]3d629afdf2
trakt_client_secret=justabunchofstuffhere
```

* `trakt_client_id` **Required**. It's used in the HTTP headers for the API calls, which is kind of a biggie.
* `trakt_client_secret`: **Optional**(ish). This is only required if you intend to make an authenticated request, which is only required by a small number of implemented API methods (see `vignette("Implemented-API-methods")`). You can use this package perfectly fine for basic data collection and you can authenticate using the package's credentials without registering an application on trakt.tv.

To get your credentials, [you have to have an (approved) app over at trakt.tv](http://trakt.tv/oauth/applications).

You theoretically never need to supply your own credentials. However, if you want to actually use this package for some project, I do not recommend relying on the package's credentials due to API rate limits.
In any case, trakt.tv is free.  
Be nice to their servers.

# Code of Conduct

Please note that the **tRakt** project is released with a [Contributor Code of Conduct](.github/CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.

Owner

  • Name: Lukas Burk
  • Login: jemus42
  • Kind: user
  • Location: Bremen, Germany
  • Company: @bips-hb // @slds-lmu

M.Sc. Biostats / WIP PhD Stats/ML / Generally, mostly #rstats

CodeMeta (codemeta.json)

{
  "@context": "https://doi.org/10.5063/schema/codemeta-2.0",
  "@type": "SoftwareSourceCode",
  "identifier": "tRakt",
  "description": "A wrapper for the <https://trakt.tv> API to retrieve data about shows and movies, including user ratings, credits and related metadata. Additional functions retrieve user-specific information including collections and history of watched items. A full API reference is available at <https://trakt.docs.apiary.io>.",
  "name": "tRakt: Get Data from 'trakt.tv'",
  "relatedLink": "https://jemus42.github.io/tRakt",
  "codeRepository": "https://github.com/jemus42/tRakt",
  "issueTracker": "http://github.com/jemus42/tRakt/issues",
  "license": "https://spdx.org/licenses/MIT",
  "version": "0.17.0.9000",
  "programmingLanguage": {
    "@type": "ComputerLanguage",
    "name": "R",
    "url": "https://r-project.org"
  },
  "runtimePlatform": "R version 4.4.3 (2025-02-28)",
  "author": [
    {
      "@type": "Person",
      "givenName": "Lukas",
      "familyName": "Burk",
      "email": "github@quantenbrot.de",
      "@id": "https://orcid.org/0000-0001-7528-3795"
    }
  ],
  "maintainer": [
    {
      "@type": "Person",
      "givenName": "Lukas",
      "familyName": "Burk",
      "email": "github@quantenbrot.de",
      "@id": "https://orcid.org/0000-0001-7528-3795"
    }
  ],
  "softwareSuggestions": [
    {
      "@type": "SoftwareApplication",
      "identifier": "covr",
      "name": "covr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=covr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "ggplot2",
      "name": "ggplot2",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=ggplot2"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "glue",
      "name": "glue",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=glue"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "kableExtra",
      "name": "kableExtra",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=kableExtra"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "knitr",
      "name": "knitr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=knitr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "rmarkdown",
      "name": "rmarkdown",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=rmarkdown"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "roxygen2",
      "name": "roxygen2",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=roxygen2"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "scales",
      "name": "scales",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=scales"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "testthat",
      "name": "testthat",
      "version": ">= 3.0.0",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=testthat"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "tidyr",
      "name": "tidyr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=tidyr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "vcr",
      "name": "vcr",
      "version": ">= 2.0.0",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=vcr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "webmockr",
      "name": "webmockr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=webmockr"
    },
    {
      "@type": "SoftwareApplication",
      "identifier": "yaml",
      "name": "yaml",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=yaml"
    }
  ],
  "softwareRequirements": {
    "1": {
      "@type": "SoftwareApplication",
      "identifier": "R",
      "name": "R",
      "version": ">= 4.1"
    },
    "2": {
      "@type": "SoftwareApplication",
      "identifier": "cli",
      "name": "cli",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=cli"
    },
    "3": {
      "@type": "SoftwareApplication",
      "identifier": "curl",
      "name": "curl",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=curl"
    },
    "4": {
      "@type": "SoftwareApplication",
      "identifier": "dplyr",
      "name": "dplyr",
      "version": ">= 1.0.0",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=dplyr"
    },
    "5": {
      "@type": "SoftwareApplication",
      "identifier": "httr2",
      "name": "httr2",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=httr2"
    },
    "6": {
      "@type": "SoftwareApplication",
      "identifier": "lubridate",
      "name": "lubridate",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=lubridate"
    },
    "7": {
      "@type": "SoftwareApplication",
      "identifier": "purrr",
      "name": "purrr",
      "version": ">= 0.2.3",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=purrr"
    },
    "8": {
      "@type": "SoftwareApplication",
      "identifier": "rappdirs",
      "name": "rappdirs",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=rappdirs"
    },
    "9": {
      "@type": "SoftwareApplication",
      "identifier": "rlang",
      "name": "rlang",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=rlang"
    },
    "10": {
      "@type": "SoftwareApplication",
      "identifier": "stringr",
      "name": "stringr",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=stringr"
    },
    "11": {
      "@type": "SoftwareApplication",
      "identifier": "tibble",
      "name": "tibble",
      "provider": {
        "@id": "https://cran.r-project.org",
        "@type": "Organization",
        "name": "Comprehensive R Archive Network (CRAN)",
        "url": "https://cran.r-project.org"
      },
      "sameAs": "https://CRAN.R-project.org/package=tibble"
    },
    "12": {
      "@type": "SoftwareApplication",
      "identifier": "utils",
      "name": "utils"
    },
    "SystemRequirements": null
  },
  "fileSize": "26289.658KB",
  "releaseNotes": "https://github.com/jemus42/tRakt/blob/main/NEWS.md",
  "readme": "https://github.com/jemus42/tRakt/blob/main/README.md",
  "contIntegration": [
    "https://github.com/jemus42/tRakt/actions/workflows/R-CMD-check.yaml",
    "https://app.codecov.io/gh/jemus42/tRakt"
  ],
  "developmentStatus": "https://www.repostatus.org/#wip",
  "keywords": [
    "trakt-api",
    "trakttv",
    "r",
    "rstats",
    "r-package",
    "trakt"
  ]
}

GitHub Events

Total
  • Create event: 5
  • Issues event: 2
  • Release event: 1
  • Watch event: 3
  • Delete event: 4
  • Issue comment event: 5
  • Push event: 38
  • Pull request event: 11
Last Year
  • Create event: 5
  • Issues event: 2
  • Release event: 1
  • Watch event: 3
  • Delete event: 4
  • Issue comment event: 5
  • Push event: 38
  • Pull request event: 11

Issues and Pull Requests

Last synced: over 1 year ago

All Time
  • Total issues: 31
  • Total pull requests: 18
  • Average time to close issues: 6 months
  • Average time to close pull requests: about 14 hours
  • Total issue authors: 1
  • Total pull request authors: 2
  • Average comments per issue: 0.39
  • Average comments per pull request: 0.0
  • Merged pull requests: 16
  • Bot issues: 0
  • Bot pull requests: 16
Past Year
  • Issues: 0
  • Pull requests: 12
  • Average time to close issues: N/A
  • Average time to close pull requests: about 19 hours
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 12
  • Bot issues: 0
  • Bot pull requests: 12
Top Authors
Issue Authors
  • jemus42 (25)
Pull Request Authors
  • dependabot[bot] (16)
  • jemus42 (4)
Top Labels
Issue Labels
enhancement (12) bug (2) discussion (1)
Pull Request Labels
dependencies (16)

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • actions/upload-artifact main composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/pkgdown.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
.github/workflows/test-coverage.yaml actions
  • actions/cache v2 composite
  • actions/checkout v2 composite
  • r-lib/actions/setup-pandoc v1 composite
  • r-lib/actions/setup-r v1 composite
DESCRIPTION cran
  • R >= 3.2 depends
  • dplyr >= 0.7.0 imports
  • httr * imports
  • jsonlite >= 0.9.14 imports
  • lubridate * imports
  • magrittr * imports
  • purrr >= 0.2.3 imports
  • rlang >= 0.1.2 imports
  • stringr * imports
  • tibble * imports
  • utils * imports
  • covr * suggests
  • ggplot2 * suggests
  • glue * suggests
  • kableExtra * suggests
  • knitr * suggests
  • rmarkdown * suggests
  • roxygen2 * suggests
  • scales * suggests
  • testthat >= 2.1.0 suggests
  • tidyr * suggests
  • yaml * suggests