-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
113 lines (78 loc) · 2.61 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# twitchr
<!-- badges: start -->
[](https://github.com/KoderKow/twitchr/actions)
[](https://lifecycle.r-lib.org/articles/stages.html#stable)
<!-- badges: end -->
R wrapper for the Twitch API.
## Installation
### From Github
```{r, eval=FALSE}
# install.packages("devtools")
devtools::install_github("koderkow/twitch")
```
## Setup
### Steps
1. Go to https://dev.twitch.tv/login
2. Login with Twitch
3. Click *Register Your Application*
4. 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*
5. Click Create
6. On the new app, click *Manage*
7. This page will have the Client ID and Client Secret
8. Open the `.Renviron` to add these values
- Run `usethis::edit_r_environ()` in the RStudio R console
9. Enter the two key values into this file with the following key names
- `TWITCH_CLIENT_ID=YOUR CLIENT ID`
- `TWITCH_SECRET=YOUR SECRET`
10. Restart the RStudio session
### More Information
Read about getting authorization tokens [here](https://dev.twitch.tv/docs/authentication/).
## Examples
```{r}
library(twitchr)
```
### Authorize
Get auth token by using `twitch_auth()`. This will be appended to future API calls
```{r}
twitch_auth()
```
### Get user information
Look up a user by their display name to get user information. This is userful to obtain `broadcaster_id` for other functions
```{r}
user <- get_users(login = "KowAndToilet")
user
```
### Get Videos
Obtain a users recent videos
```{r}
videos <- get_videos(user_id = user$id)
```
### Get Followers
Display the followers of a channel
```{r}
followers <- get_follows(to_id = user$id)
```
### Get chatters
Display who is currently in a broadcasters chat
```{r}
chatters <- get_chatters("KowAndToilet")
```
### Other functions
I have covered most of the Twitch API endpoints which can be viewed [here](https://koderkow.github.io/twitchr/reference/index.html). If there are any you would like added please create an issue! :)
## Thanks to
- [Freguglia](https://github.com/Freguglia/rTwitchAPI/) for getting me started on the oauth code