get_subreddits: Get a dataframe of subreddits

Description Usage Arguments Details Value Examples

Description

Subreddits can be sorted by creation date or popularity. Also allows searching for subreddits with search queries.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
get_subreddits(
  type = c("popular", "new", "default", "search"),
  accesstoken,
  query = NULL,
  sort = c("relevance", "activity"),
  limit = 100,
  after = NULL,
  before = NULL,
  output = c("df", "json", "all"),
  verbose = FALSE,
  retry = FALSE
)

Arguments

type

The type of list that is requested. Possible values are:

  • popular Subreddits that are popular right now

  • new Newly created subreddits

  • default Default subreddits that users are subscribed to when they sign up for reddit.

  • search Search for subreddits with a query.

accesstoken

The accesstoken required to access the endpoint. Scope must be "read".

query

Search terms for type search. Must be less than 512 characters.

sort

The order in which results from type search should be sorted. Possible values are "relevance" and "activity".

limit

The maximum number of subreddits to return. Must be a number between 1 and 100.

after

The fullname of an item serving as anchor in the request. Items after this item in the listing are returned.

before

The fullname of an item serving as anchor in the request. Items before this item in the listing are returned.

output

What the function should return. Choose json for an unparsed json object, df for a parsed object in form of a dataframe, and all for a list containg the json object, a dataframe, and the before and after anchors (if those exist for the endpoint).

verbose

A logical flag whether information about the data extraction should be printed to the console.

retry

A logical flag whether a failed api request should be retried. Requests will be tried up to three times with varying time intervals between requests.

Details

More info at https://www.reddit.com/dev/api/

Value

New or popular subreddits as a dataframe, json object or a list containing both.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
read_token <- get_token(scope = "read",
                        useragent = my_useragent,
                        username = my_username,
                        password = my_password,
                        client_id = my_client_id,
                        client_secret = my_client_secret)
                        
#type = "popular" will show subreddits that are popular right now
popular_subs <- get_subreddits(type = "popular",
                              limit = 10,
                              accesstoken = read_token)

#Searches for subreddits can be performed with type "search"
search_subs <- get_subreddits(type = "search",
                             accesstoken = read_token,
                             limit = 10,
                             query = "soccer",
                             sort = "activity")

## End(Not run)

jfeldhege/redditoR documentation built on April 2, 2020, 9:42 p.m.