R wrapper for the Twitch API.
# install.packages("devtools")
devtools::install_github("koderkow/twitch")
- Go to https://dev.twitch.tv/login
- Login with Twitch
- Click Register Your Application
- Fill out the App information
- Name: Name of the app. Something to label it for the own personal use
- OAuth Redirect URLs: Fill this in if one if you have one. If not
put
http://localhost
- Category: Pick related category such as Analytics Tool
- Click Create
- On the new app, click Manage
- This page will have the Client ID and Client Secret
- Open the
.Renviron
to add these values- Run
usethis::edit_r_environ()
in the RStudio R console
- Run
- Enter the two key values into this file with the following key names
TWITCH_CLIENT_ID=YOUR CLIENT ID
TWITCH_SECRET=YOUR SECRET
- Restart the RStudio session
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! :)
- Freguglia for getting me started on the oauth code