> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Reddit

> Query subreddit posts, stats, and trends with RedditTools using praw script-app credentials.

## Prerequisites

1. Create or sign in to a Reddit account at [reddit.com](https://www.reddit.com).
2. Complete Reddit's [Data API access process](https://support.reddithelp.com/hc/en-us/articles/14945211791892-Developer-Platform-Accessing-Reddit-Data).
3. Create a script app at [reddit.com/prefs/apps](https://www.reddit.com/prefs/apps).
4. Copy the app's client ID and client secret.

RedditTools can perform read-only operations with the client ID and client secret. Set a username and password only for write operations.

```python theme={null}
from agno.agent import Agent
from agno.tools.reddit import RedditTools

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

agent = Agent(
    instructions=[
        "Use your tools to answer questions about Reddit content and statistics",
        "Respect Reddit's content policies and NSFW restrictions",
        "When analyzing subreddits, provide relevant statistics and trends",
    ],
    tools=[RedditTools()],
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("What are the top 5 posts on r/SAAS this week ?", stream=True)
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno openai praw
```

**2. Export required credentials**

```bash Mac/Linux theme={null}
export REDDIT_CLIENT_ID="your_reddit_client_id"
export REDDIT_CLIENT_SECRET="your_reddit_client_secret"
export REDDIT_USER_AGENT="platform:app_id:version (by /u/username)"
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:REDDIT_CLIENT_ID="your_reddit_client_id"
$Env:REDDIT_CLIENT_SECRET="your_reddit_client_secret"
$Env:REDDIT_USER_AGENT="platform:app_id:version (by /u/username)"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

**3. Set optional write credentials**

Set `REDDIT_USERNAME` and `REDDIT_PASSWORD` for write operations.

```bash Mac/Linux theme={null}
export REDDIT_USERNAME="your_reddit_username"
export REDDIT_PASSWORD="your_reddit_password"
```

```bash Windows theme={null}
$Env:REDDIT_USERNAME="your_reddit_username"
$Env:REDDIT_PASSWORD="your_reddit_password"
```

**4. Run the example**

Save the code above as `reddit_tools.py`, then run:

```bash theme={null}
python reddit_tools.py
```

Full source: [cookbook/91\_tools/reddit\_tools.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/91_tools/reddit_tools.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.