Skip to content
sabbatiw edited this page Mar 14, 2019 · 59 revisions

Welcome to the node-red-contrib-node-reddit wiki!

Table of Contents

Nodes

  1. Config
  2. Stream
  3. Get
  4. Create
  5. Reply
  6. Search
  7. Edit
  8. Delete
  9. React

Dynamically populating fields

Contributors

References

Nodes

Config

Authentication for the Reddit API

Details

To create a Reddit app and obtain its Client ID and Client Secret, log in to your Reddit account and visit this link.

There are 3 ways to provide authentication:

  • Username/password: For long-term access. Possible for script-type apps only.
  • Refresh token: For long-term access. Visit here to generate a token.
  • Access token: For short-term access. Expires in one hour. Visit here to generate a token

Stream

Stream submissions and comments from a subreddit or PMs from your inbox.

Inputs

stream selection
choose comments, submissions, or PMs.
subreddit string
the subreddit to stream (unused for PMs).
filter selection
choose which type of messages to stream from Inbox
mark as read checkbox
polltime number
the refresh rate in seconds.
timeout number
the length of time to stream in seconds.

Outputs

Standard output

payload
details of the comment, submission, or PM.

Standard error

payload
the standard error of the command.

Details

Prefixes

Exclude the "r/" when entering your subreddit. "r/subreddit" will be used for the display name if name is left empty.

"u/credentials.username" will be used for the display name if name is left empty.

Polltime

The polltime is the number of seconds (between 2 and 3600) that the stream polls for updates. Reddit enforces a ratelimit of 30 polls per minute. If your stream continues to hit the ratelimit, consider increasing the polltime.

Timeout

The timeout will stop the stream after the desired number of seconds. If left blank, the stream will continue until the node is deleted from the flow, an error is thrown, or node-RED is shutdown.

Get

Get submissions, comments, or personal messages from a subreddit, user, your inbox or the listing’s id, according to its configuration.

Inputs

type
the type of content to be retrieved
source
the source of the content
subreddit
the subreddit from which submissions or comments will be retrieved
user
the user who submitted the submissions or comments
content_id
the id of the listing to be retrieved
sort
the sorting method for the Reddit content
time
the time range for the Reddit content
fetch_all
the option to retrieve all possible content
limit
the number of listings to be retrieved
depth
an upper bound for replies in the comment tree

Outputs

Standard output

payload
details of the comment, submission, or PM.

Standard error

payload
the standard error of the command.

Details

Prefixes

Exclude the "r/" when entering a subreddit and the "u/" when entering a user

Populating fields

All text input properties may be hardcoded via text or dynamically populated via mustache syntax relative to the incoming msg object.

For example, if the target subreddit is located in msg.payload.target, then you can fill in {{payload.target}} in the subreddit field.

Comments

When a subreddit is the source, the newest comments from the subreddit are retrieved.

When a submission is the source, a comment tree is retrieved, broken up by the parent comments. Replies to these comments, if any, will be in msg.payload.replies.

Fetch all

The fetch_all property is only accessible when retrieving comments or submissions from a user, your own PMs, or comments from a submission. If set to false, the limit option will determine the number of listings to be retrieved. The Reddit API docs outline the rate limits.

Create

Create a new Reddit submission or PM.

Inputs

type
choose self-, link-, or cross-post, or PM.
subreddit
the subreddit to submit to.
title
the title of the submission.
text
the text of a self-post.
url
the url of a link-post.
original
the original listing name for a cross-post.
recipient
the recipient of the PM.
subject
the subject of the PM.
message
the mesage of a PM.

Outputs

Standard output

payload
the name of the new listing

Standard error

payload
the standard error of the command.

Details

Prefixes

Exclude the "r/" when entering your subreddit. "r/subreddit" will be used for the display name if name is left empty.

Exclude the "u/" when entering your recipient. "u/recipient" will be used for the display name if name is left empty.

Populating fields

All text input properties may be hardcoded via text or dynamically populated via mustache syntax relative to the incoming msg object.

For example, if the target subreddit is located in msg.payload.target, then you can fill in {{payload.target}} in the subreddit field.

Reply

Reply to Reddit submissions, comments, or PMs

Inputs

type
the type of content to be replied to
content_id
the id of the Reddit content to be replied to
text
the body of the response

Outputs

Standard output

payload
details of the comment, submission, or PM.

Standard error

payload
the standard error of the command.

Details

Populating fields

content_id and text may be hardcoded via text or dynamically populated via mustache syntax relative to the incoming msg object.

For example, if the target content_id is located in msg.payload.target, then you can fill in {{payload.target}} in the content_id field.

Search

Perform a Reddit search query in a subreddit.

Inputs

subreddit
the subreddit to be searched
query
the search query
time
the time range of the search results
sort
the sort filter for the results

Outputs

Standard output

payload
details of the submission.

Standard error

payload
the standard error of the command.

Outputs

Standard output

payload
details of the comment, submission, or PM.

Standard error

payload
the standard error of the command.

Details

Prefixes

Exclude the "r/" when entering a subreddit and the "u/" when entering a user

Populating fields

content_id and text may be hardcoded via text or dynamically populated via mustache syntax relative to the incoming msg object.

For example, if the target query is located in msg.payload.target, then you can fill in {{payload.target}} in the query field.

Edit

Edit a Reddit submission or comment.

Inputs

content_id
the Reddit id of the content to be edited.
type
the type of the content to be edited.
textstring
the edited content.

Outputs

Standard output

payload
details of the edited comment or submission.

Standard error

payload
the standard error of the command.

Details

Ownership

You can only edit your own Reddit content.

Populating fields

All text input properties may be hardcoded via text or dynamically populated via mustache syntax relative to the incoming msg object.

For example, if the target content_id is located in msg.payload.target, then you can fill in {{payload.target}} in the content_id field.

Delete

Delete a Reddit submission, comment, or PM.

Inputs

content_id
the Reddit id of the content to be deleted.
type
the type of the content to be deleted.

Outputs

Standard output

none

Details

Ownership

You can only delete your own Reddit content.

Populating fields

All text input properties may be hardcoded via text or dynamically populated via mustache syntax relative to the incoming msg object.

For example, if the target content_id is located in msg.payload.target, then you can fill in {{payload.target}} in the content_id field.

Standard error

payload
the standard error of the command.

React

Save/unsave and/or vote/unvote on Reddit content.

Inputs

content_id
the Reddit id of the content.
type
the type of the content.

Outputs

Standard output

none

Standard error

payload
the standard error of the command.

Details

Populating fields

All text input properties may be hardcoded via text or dynamically populated via mustache syntax relative to the incoming msg object.

For example, if the target content_id is located in msg.payload.target, then you can fill in {{payload.target}} in the content_id field.

Dynamically populating fields

For all nodes other than config and stream, all text fields may be hardcoded via text or dynamically populated via mustache syntax relative to the incoming msg object.

For example, let's say you're getting hot submissions from a subreddit using the get node. If the target subreddit is located in msg.payload.target, then you can fill in {{payload.target}} in the subreddit field.

Contributors

References