A cross-platform PowerShell 7+ module for authenticating with Reddit and retrieving posts from subreddits.
This module provides cmdlets to authenticate with the Reddit API using OAuth 2.0 client credentials flow and fetch posts based on subreddit, sort order, and timeframe. It requires PowerShell 7+ and relies on environment variables for storing Reddit API client ID and secret.
Full documentation is available at: https://lukeevanstech.github.io/PSReddit/
- OAuth authentication (using environment variables for secrets)
- Retrieve posts by subreddit with
Get-RedditSubredditPost - Retrieve posts from specific users with
Get-RedditUserPost - Support for various sort types (Top, New, Hot, etc.) and timeframes (for Top/Controversial)
- Pester tests for integration testing
- Comprehensive MkDocs documentation
- PowerShell 7+
- Reddit API Client ID and Secret stored in environment variables:
REDDIT_CLIENT_IDREDDIT_CLIENT_SECRET
# Import the module locally from the source directory
Import-Module ./src/PSReddit/PSReddit.psd1 -Force# Set environment variables (replace with your actual credentials)
$env:REDDIT_CLIENT_ID = 'your-client-id'
$env:REDDIT_CLIENT_SECRET = 'your-client-secret'
# Get an OAuth token
$token = Get-RedditOAuthToken
# Get the top 5 posts from the 'powershell' subreddit from the last day
$posts = Get-RedditSubredditPost -Subreddit 'powershell' -Sort Top -LastDay -Count 5
# Display post titles
$posts.titleSee the documentation for full usage, installation, and development information.
- Run tests:
Invoke-Pester ./src/Tests -CI(Ensure Pester module is installed) - Style Guides: Refer to project configuration files (e.g.,
.editorconfig,PSScriptAnalyzerSettings.psd1). - Contributions welcome! Please follow standard fork & pull request workflow.
Luke Evans