"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:

    Get information about your own account:

    Get information about a specific user:

    Get information about multiple users:

    Get information on your account karma by subreddit:

    Get your karma from a specific subreddit:

    Get basic information about your trophies:

    Get trophies from a list of users:

    Get detailed trophy information about a specific user:

    Get information about several users' recent activity:

    Get information about a specific post using its URL:

    Use a "GlobalID" instead of a URL:

    Retrieve data for several posts:

    Get information about a specific subreddit:

    Retrieve data on several subreddits:

    Get posts from a specific subreddit:

    Examine one of the results:

    Get posts from different subreddits:

    Examine a single post:

    Retrieve comments on a specific post:

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

    Retrieve data for multiple posts:

    Retrieve comments to the post up to 4 levels deep:

    Get replies to a comment:

    Get replies to multiple comments: