Skip to content

jfeldhege/redditoR

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

76 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

redditoR: An R wrapper for reddit

Introduction

The goal of redditoR is to provide an R wrapper to the API of reddit.com. You need to have an account with reddit to use redditR. Additionally, an app needs to be defined in the settings of your account here.

Further information about the API can be found here.

Installation

You can install the current version version from GitHub with:

# install.packages("devtools")
devtools::install_github("jfeldhege/redditoR")

Example

This is an example workflow to access data through the reddit API:

#Load the package
library(redditoR)

# Get a token for the scope "read" with the username and password of your account, 
#the client id and secret of your app and a useragent.
read_token <- get_token(scope = "read", useragent = useragent,
                        username = username, password = password,
                        client_id = client_id, client_secret = client_secret)

# Get 10 new posts from the subreddit r/soccer
soccer_posts <- get_posts(subreddit = "soccer",
                   accesstoken = read_token,
                   sort = "new",
                   limit = 10)  

For the second example we will get the top 10 comments made by Barack Obama on his account U/PResidentObama.

#For the comments on his account we need an access token with the "history" scope.
history_token <- get_token(scope = "history", useragent = useragent,
                        username = username, password = password,
                        client_id = client_id, client_secret = client_secret)

#Get the top comments with the function get_user and type = "comments
top_comments <- get_user(user = "PresidentObama",
                   type = "comments",
                   accesstoken = history_token,
                   sort = "top",
                   time = "all",
                   limit = 10)

Meta

  • Please report any issues or bugs.
  • License: GPL-3
  • Cite with citation('redditoR')

About

The redditoR package

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages