"Reddit" (Service Connection)

Connect to Reddit using the Wolfram Language to retrieve data on user accounts, posts, comments, and private messages.

Connecting & Authenticating

ServiceConnect["Reddit"] creates a connection to the Reddit API. If a previously saved connection can be found, it will be used; otherwise, a new authentication request will be launched.

Requests

ServiceExecute["Reddit","request","params"] sends a request to the Reddit API, using parameters params. The following give possible requests.

Private Account Information

Requests:

"AccountData" data about the authenticated user's account

"AccountFriends" list of authenticated user's friends

"AccountKarma" dataset of authenticated user's karma

Private Messages

Requests:

"PrivateMessages" retrieves the mailbox from the authenticated user's account

Parameters:
  • "Source""Inbox"mailbox source
    MaxItems25maximum number of messages to retrieve
    "StartIndex"1starting position of results
    "ShowThumbnails"Trueimport thumbnail images
  • Public Account Information

    Requests:

    "UserData" profile information for a specified user

    Parameters:
  • "User"authenticated userusername
  • Requests:

    "UserTrophies" earned trophies for a specified user

    Parameters:
  • "User"authenticated userusername
    "Elements""FullData"one of "FullData" or "Icon"
    "ShowThumbnails"Trueimport thumbnail images
  • Requests:

    "UserActivity" get recent user activity data

    Parameters:
  • "User"authenticated userusername
    "SortBy""New"sorting method
    "Type""Overview"type of user activity
    MaxItems25maximum number of results to retrieve
    "StartIndex"1starting position of results
    "ShowThumbnails"Falseimport thumbnail images
  • Detailed Information on Subreddits and Posts

    Requests:

    "GlobalIDInformation" get data for a "GlobalID"

    Parameters:
  • "GlobalID"(required)"GlobalID" list of kinds t1_, t3_, or t5_
    "ShowThumbnails"Falseimport thumbnail images
  • Requests:

    "PostInformation" get data for posts

    Parameters:
  • "Post"(required)URL or "GlobalID" of a post
    "ShowThumbnails"Falseimport thumbnail images
  • Requests:

    "SubredditInformation" get data for a subreddit

    Parameters:
  • "Subreddit"(required)URL or "GlobalID" of a subreddit
    "ShowThumbnails"Falseimport thumbnail images
  • Contents of Posts and Comments

    Requests:

    "SubredditPosts" retrieves the posts from a subreddit

    Parameters:
  • "Subreddit"(required)URL or "GlobalID" of a subreddit
    "SortBy""New"sorting method
    MaxItems25maximum number of posts to retrieve
    "StartIndex"1starting position of results
    "ShowThumbnails"Falseimport thumbnail images
  • Requests:

    "PostCommentsData" retrieves the comments from a post

    Parameters:
  • "Post"(required)URL or "GlobalID" of a post
    "Depth"1depth of the comment tree
    MaxItems25number of posts to retrieve, to a maximum of 500; only works with depth set to 1
    "StartIndex"1starting position of results
    "ShowThumbnails"Falseimport thumbnail images
  • Requests:

    "CommentReplyData" retrieves the replies to a comment

    Parameters:
  • "Comment"(required)URL or "GlobalID" of a comment
    "Depth"1depth of the comment tree
    MaxItems25number of posts to retrieve, to a maximum of 500; only works with depth set to 1
    "StartIndex"1starting position of results
    "ShowThumbnails"Falseimport thumbnail images
  • ServiceNotes

    "GlobalID" refers to Reddit API fullnames, which include prefixes that identify the specific type of object:
  • "t1_"comment
    "t2_"account
    "t3_"link or post
    "t4_"message or PM
    "t5_"subreddit
    "t6_"award
  • Parameter Details

    Possible settings for "Elements" include:
  • "Icon"return a list of images
    "FullData"return a dataset with all available fields
    "Source"one from "Inbox", "Unread", or "Sent"
    "SortBy"one from "New", "Top", "Hot", or "Controversial"; "Rising" is also available for "SubredditPosts" request
    "Type"one from "Overview", "Submitted", "Comments", "Upvoted", "Downvoted", "Hidden", "Saved", or "Gilded"
  • Examples

    Basic Examples  (1)

    Create a new connection:

    In[1]:=
    Click for copyable input
    Out[1]=

    Get information about your own account:

    In[2]:=
    Click for copyable input
    Out[2]=

    Get information about a specific user:

    In[3]:=
    Click for copyable input
    Out[3]=

    Get information about multiple users:

    In[4]:=
    Click for copyable input
    Out[4]=

    Get information on your account karma by subreddit:

    In[5]:=
    Click for copyable input
    Out[5]=

    Get your karma from a specific subreddit:

    In[6]:=
    Click for copyable input
    Out[6]=

    Get basic information about your trophies:

    In[7]:=
    Click for copyable input
    Out[7]=

    Get trophies from a list of users:

    In[8]:=
    Click for copyable input
    Out[8]=

    Get detailed trophy information about a specific user:

    In[9]:=
    Click for copyable input
    Out[9]=

    Get information about several users' recent activity:

    In[10]:=
    Click for copyable input
    Out[10]=

    Get information about a specific post using its URL:

    In[11]:=
    Click for copyable input
    Out[11]=

    Use a "GlobalID" instead of a URL:

    In[12]:=
    Click for copyable input
    Out[12]=

    Retrieve data for several posts:

    In[13]:=
    Click for copyable input
    Out[13]=

    Get information about a specific subreddit:

    In[14]:=
    Click for copyable input
    Out[14]=

    Retrieve data on several subreddits:

    In[15]:=
    Click for copyable input
    Out[15]=

    Get posts from a specific subreddit:

    In[16]:=
    Click for copyable input
    Out[16]=

    Examine one of the results:

    In[17]:=
    Click for copyable input
    Out[17]=

    Get posts from different subreddits:

    In[18]:=
    Click for copyable input
    Out[18]=

    Examine a single post:

    In[19]:=
    Click for copyable input
    Out[19]=

    Retrieve comments on a specific post:

    In[20]:=
    Click for copyable input
    Out[20]=

    Create a WordCloud from the comments, removing profanity with the built-in "Profanity" classifier:

    In[21]:=
    Click for copyable input
    Out[21]=

    Retrieve data for multiple posts:

    In[22]:=
    Click for copyable input
    Out[22]=

    Retrieve comments to the post up to 4 levels deep:

    In[23]:=
    Click for copyable input
    Out[23]=
    In[24]:=
    Click for copyable input
    Out[24]=

    Get replies to a comment:

    In[25]:=
    Click for copyable input
    Out[25]=

    Get replies to multiple comments:

    In[26]:=
    Click for copyable input
    Out[26]=