# Reddit on boxd

> Reddit is a social news platform with user-driven communities (subreddits), offering content sharing, discussions, and viral marketing opportunities for brands.

- Page: https://boxd.sh/integrations/reddit/
- CLI: `run reddit` (23 commands, 7 marked common)
- SDK: `import { reddit } from "@boxd/run"`; every parameter and response type is at `@boxd/run/reddit`
- Triggers: none
- Connect: `run auth reddit` (Sign in with Reddit), or https://app.boxd.sh/integrations/detail/reddit
- All integrations: https://boxd.sh/integrations/ (Markdown: https://boxd.sh/integrations/index.md)

## From the shell

```sh
run auth reddit      # once: prints a link to connect your account
run reddit           # list its commands
run reddit get-controversial-posts
```

Parameters are flags (`--flag value`); object and array parameters take a JSON string. Output is YAML, or JSON with `--json`. Calls use your own connection; `--scope <name>` uses a connection shared with your team.

## From a script

```ts
import { every, reddit } from "@boxd/run";

every("1 hour", async () => {
  const result = await reddit.getControversialPosts({});
  console.log(result);
});
```

Run it with `run reddit.run.ts`. Reddit has no triggers; `every()` polls on a schedule, keeps the script running as a job, and wakes the machine when it is due.

## Commands

Required flags are listed; `run reddit <command> --help` lists the optional ones. "common" marks what `run reddit` shows without `--all`.

| Command | SDK method | Required flags | Optional | Description |
|---|---|---|---|---|
| `create-post` | `reddit.createPost()` | `--subreddit` `--title` | 4 | Creates a new text or link post on a specified, existing Reddit subreddit, optionally applying a flair |
| `delete-comment` | `reddit.deleteComment()` | `--id` | 0 | Deletes a Reddit comment, identified by its fullname ID, if it was authored by the authenticated user |
| `delete-post` | `reddit.deletePost()` | `--id` | 0 | Permanently and irreversibly deletes a Reddit post by its ID |
| `edit-comment-or-post` ·common | `reddit.editCommentOrPost()` | `--text` `--thing-id` | 0 | Edits the body text of the authenticated user's own existing comment or self-post on Reddit; cannot edit link posts or titles |
| `get` ·common | `reddit.get()` | `--sort` | 6 | Retrieve a listing of Reddit posts sorted by the specified criteria (hot, new, top, rising, controversial, best) |
| `get-controversial-posts` ·common | `reddit.getControversialPosts()` | — | 6 | Retrieve controversial posts from all subreddits with time filters |
| `get-me-prefs` | `reddit.getMePrefs()` | — | 1 | Retrieve preference settings of the logged in user |
| `get-new` ·common ·deprecated | `reddit.getNew()` | `--subreddit` | 4 | Use RetrieveRedditPost instead |
| `get-r-top` ·common ·deprecated | `reddit.getRTop()` | `--subreddit` | 7 | Use RetrieveRedditPost with sort='top' and time_filter set instead - it now supports the same hour/day/week/month/year/all time filtering |
| `get-random` | `reddit.getRandom()` | — | 1 | Retrieve a random public Reddit post from any subreddit |
| `get-scopes` | `reddit.getScopes()` | — | 0 | Retrieve all available OAuth scopes supported by the Reddit API |
| `get-subreddits-search` ·common | `reddit.getSubredditsSearch()` | `--q` | 8 | Search subreddits by title and description |
| `get-subrules` | `reddit.getSubrules()` | `--subreddit` | 1 | Fetch the explicit posting rules for a subreddit to ensure compliance before posting or commenting |
| `get-user-about` ·common | `reddit.getUserAbout()` | `--username` | 0 | Retrieves information about a specified Reddit user account, including karma scores and gold status |
| `get-user-flair` | `reddit.getUserFlair()` | `--subreddit` | 3 | Fetches the list of user flair assignments for a given subreddit |
| `get-username-available` | `reddit.getUsernameAvailable()` | `--user` | 0 | Check whether a username is available for registration on Reddit |
| `list-subpost-flairs` | `reddit.listSubpostFlairs()` | `--subreddit` | 0 | List available link/post flairs for a subreddit (including flair_template_id) so posts can satisfy flair-required validation |
| `post-comment` | `reddit.postComment()` | `--text` `--thing-id` | 0 | Posts a comment on Reddit, replying to an existing submission (post) or another comment |
| `retrieve-post` | `reddit.retrievePost()` | `--subreddit` | 8 | Retrieves posts from a specified, publicly accessible subreddit |
| `retrieve-post-comments` | `reddit.retrievePostComments()` | `--article` | 3 | Retrieves all comments for a Reddit post given its base-36 article ID |
| `retrieve-specific-comment` | `reddit.retrieveSpecificComment()` | `--id` | 0 | Retrieves detailed information for a single Reddit comment or post using its fullname |
| `search-across-subreddits` | `reddit.searchAcrossSubreddits()` | `--search-query` | 7 | Searches Reddit for posts using a query |
| `toggle-inbox-replies` | `reddit.toggleInboxReplies()` | `--id` `--state` | 0 | Enable or disable inbox replies for a submission or comment |

## Docs

- [run CLI](https://docs.boxd.sh/cli/run): Call connected integrations from the shell, connect new ones, and run automations.
- [Quickstart](https://docs.boxd.sh/guides/integrations/quickstart): Connect an integration, call it from the shell, and turn a script into an automation.
- [Connections](https://docs.boxd.sh/guides/integrations/connections): Connect an account once, for yourself or for your whole organization.
- [Scripts](https://docs.boxd.sh/guides/automations/scripts): Typed integrations, triggers, schedules and state in a .run.ts file.
- [Jobs](https://docs.boxd.sh/guides/automations/jobs): How a script becomes a background job: states, retries, sleep and wake.
- [Beyond the catalog](https://docs.boxd.sh/guides/automations/beyond-the-catalog): Reach your own APIs, databases and cloud accounts from a script.
