Retrieve and analyze detailed statistics for your Reddit posts with this Python tool.
- Fetch detailed statistics for your recent Reddit posts
- Display comprehensive metrics including upvotes, downvotes, comments, awards
- Export data to CSV format for further analysis
- Easy configuration with environment variables
- Post ID, title, subreddit
- URLs (post URL and permalink)
- Creation date and time (UTC)
- Upvotes, downvotes, score, upvote ratio
- Number of comments
- Awards received
- Post metadata (self post, NSFW, spoiler, stickied, locked)
git clone https://github.com/codinghubytb/reddit-post-stats.git
cd reddit-post-statspip install -r requirements.txt- Go to Reddit Apps
- Click "Create App" or "Create Another App"
- Fill in the details:
- name: Choose any name (e.g., "Post Statistics Tool")
- App type: Select "script"
- description: Optional
- about url: Optional
- redirect uri: Use
http://localhost:8080
- Click "Create app"
- Note your client_id (under the app name) and client_secret
Copy the example configuration file:
cp config.example.py config.pyEdit config.py with your Reddit credentials:
REDDIT_CLIENT_ID = "your_client_id_here"
REDDIT_CLIENT_SECRET = "your_client_secret_here"
REDDIT_USERNAME = "your_reddit_username"
REDDIT_PASSWORD = "your_reddit_password"
REDDIT_USER_AGENT = "RedditStatsGetter/1.0"python test_config.pyIf everything is configured correctly, you should see:
✅ Configuration is valid!
✅ Successfully connected to Reddit API
✅ Authenticated as: your_username
Run the main script:
python main.pyBy default, it fetches statistics for your 10 most recent posts. To change the number of posts:
# In main.py, modify the limit parameter
posts_stats = get_user_posts_detailed(limit=25) # Fetch 25 postsThe script generates:
- Console output: Formatted display of all post statistics
- CSV file:
reddit_posts_stats.csvwith all data for spreadsheet analysis
================================================================================
📊 Reddit Posts Statistics - 10 posts
================================================================================
Post #1: My Amazing Post Title
Subreddit: python
URL: https://reddit.com/r/python/comments/abc123/my_amazing_post_title
Created UTC: 2024-11-10 14:30:00
👍 Upvotes: 1250 | 👎 Downvotes: 45 | Score: 1205 | Ratio: 0.965
💬 Comments: 87 | Awards: 3 | Gilded: 1
Self Post: True | NSFW: False | Spoiler: False | Stickied: False | Locked: False
--------------------------------------------------------------------------------
reddit-post-statistics/
│
├── src/
│ └── script.py # Main script with all functions
├── main.py # Entry point
├── config.py # Your credentials (DO NOT COMMIT)
├── config.example.py # Configuration template
├── test_config.py # Configuration validator
├── requirements.txt # Python dependencies
├── README.md # This file
└── .gitignore # Git ignore file
- Never commit
config.pyto version control - Keep your Reddit credentials secure
- The
.gitignorefile is configured to excludeconfig.py - Consider using environment variables for production use
- Make sure you've created
config.pyfromconfig.example.py - Verify all required variables are set in
config.py
- Double-check your Reddit API credentials
- Ensure your Reddit account password is correct
- Verify your app is set as "script" type
- Reddit API has rate limits
- Wait a few minutes before trying again
- Consider reducing the number of posts fetched
See requirements.txt for all dependencies. Main requirement:
praw(Python Reddit API Wrapper)
Happy analyzing! 📊