> ## Documentation Index
> Fetch the complete documentation index at: https://stars-components.js.org/llms.txt
> Use this file to discover all available pages before exploring further.

# @wolfstar/reddit-helpers

> Fetch and normalize Reddit posts for Star bots.

<CodeGroup>
  ```bash npm theme={"system"}
  npm install @wolfstar/reddit-helpers
  ```

  ```bash pnpm theme={"system"}
  pnpm add @wolfstar/reddit-helpers
  ```

  ```bash yarn theme={"system"}
  yarn add @wolfstar/reddit-helpers
  ```

  ```bash bun theme={"system"}
  bun add @wolfstar/reddit-helpers
  ```
</CodeGroup>

<CardGroup cols={2}>
  <Card title="npm" icon="npm" horizontal href="https://npmx.dev/package/@wolfstar/reddit-helpers" />

  <Card title="Source" icon="github" horizontal href="https://github.com/wolfstar-project/stars-components/tree/main/packages/reddit-helpers" />
</CardGroup>

## Description

Very basic Reddit helper functions for several Star bots to ensure we do not duplicate code.

Note that this package only does [Application Only Oauth](https://github.com/reddit-archive/reddit/wiki/OAuth2#application-only-oauth) and requires
an application of the "Installed" type!

## Features

* Powered by the `@wolfstar/safe-fetch` package

## Usage

First of all, you should make sure to define the following environment variables for your process:

* `REDDIT_CLIENT_ID`: The Client ID of your Reddit application (generated at
  [Reddit Apps Dashboard](https://old.reddit.com/prefs/apps/))
* `REDDIT_DEVICE_ID`: A unique, per-device ID generated by your client.

After this, you can use the functions exported from this package to interact with the Reddit API.

### What value should I use for device\_id?

You should generate and save unique ID on your client. The ID should be unique per-client. A randomized or pseudo-randomized value is acceptable for generating the ID; however, you should retain and re-use the same device\_id when renewing your access token.
