get_user: Get posts and comments from a specified user

Description Usage Arguments Details Value See Also Examples

Description

This function returns posts and/or comments made by one user. They can be requested for a specific timeframe or sort order.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
get_user(
  user,
  accesstoken,
  type = c("overview", "comments", "submitted", "gilded"),
  sort = c("new", "hot", "controversial", "top"),
  time = c("all", "hour", "day", "week", "month", "year"),
  limit = 100,
  before = NULL,
  after = NULL,
  output = c("df", "json", "all"),
  verbose = FALSE,
  retry = FALSE
)

Arguments

user

The username of the user for which posts and comments are requested.

accesstoken

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

type

The type of content that is requested for the user. Possible valuesare:

  • overview Contains posts and comments.

  • comments Only comments.

  • submitted Only posts.

  • gilded Posts and comments that have received awards.

sort

The order in which the posts or comments of the user should be ordered when accessing them. Possible values are:

  • new: Returns newest comments or posts

  • hot: Returns highly upvoted comments or posts currently

  • controversial: Returns comments or posts that received a lot of upvotes and downvotes in a certain imeframe.Timeframe can be specified with time.

  • top: Returns most upvoted comments posts in a certain timeframe.Timeframe can be specified with time.

time

The timeframe for the sort order "controversial" and "top". Possible values are:

  • hour

  • day

  • week

  • month

  • year

  • all for posts or comments from all time. The default value if time is not specified.

limit

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

before

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

after

The fullname of an item serving as anchor in the request. Items after 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

Posts, comments or both for the specified user as a dataframe, json object or a list containing both.

See Also

get_user_comments and get_submissions

Examples

 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
## Not run: 
history_token <- get_token(scope = "history",
                           useragent = my_useragent,
                           username = my_username,
                           password = my_password,
                           client_id = my_client_id,
                           client_secret = my_client_secret)

# overview returns posts and comments
overview <- get_user(user = "_KeanuReeves",
                     type = "overview",
                     accesstoken = history_token,
                     sort = "top", time = "all",
                     limit = 10)

# type = "comments" returns only comments
user_comments <- get_user(user = "_KeanuReeves",
                          type = "comments",
                          accesstoken = history_token,
                          sort = "top", time = "all",
                          limit = 10)

# type = "submitted" returns only posts
user_comments <- get_user(user = "_KeanuReeves",
                          type = "submitted",
                          accesstoken = history_token,
                          sort = "top", time = "all",
                          limit = 10)

#
gilded <- get_user(user = "_KeanuReeves",
                  type = "gilded",
                  accesstoken = history_token,
                  sort = "hot",
                  time = "all",
                  limit = 10)

## End(Not run)

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