R wrapper for the Twitch API.
# install.packages("devtools")
devtools::install_github("koderkow/twitch")
http://localhost
.Renviron
to add these valuesusethis::edit_r_environ()
in the RStudio R consoleTWITCH_CLIENT_ID=YOUR CLIENT ID
TWITCH_SECRET=YOUR SECRET
Read about getting authorization tokens here.
library(twitchr)
Get auth token by using twitch_auth()
. This will be appended to future
API calls
twitch_auth()
Look up a user by their display name to get user information. This is
userful to obtain broadcaster_id
for other functions
user <- get_users(login = "KowAndToilet")
user
#> # A tibble: 1 x 10
#> id login display~1 type broad~2 descr~3 profi~4 offli~5 view_~6
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 613890167 kowandtoilet kowandto~ "" affili~ Kyle a~ https:~ https:~ 4989
#> # ... with 1 more variable: created_at <dttm>, and abbreviated variable names
#> # 1: display_name, 2: broadcaster_type, 3: description, 4: profile_image_url,
#> # 5: offline_image_url, 6: view_count
#> # i Use `colnames()` to see all variable names
Obtain a users recent videos
videos <- get_videos(user_id = user$id)
Display the followers of a channel
followers <- get_follows(to_id = user$id)
Display who is currently in a broadcasters chat
chatters <- get_chatters("KowAndToilet")
I have covered most of the Twitch API endpoints which can be viewed here. If there are any you would like added please create an issue! :)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.