Reddit parser for w_popularity.
- Primary: public JSON API at
https://www.reddit.com/user/<handle>/about.json(channel) and/user/<handle>/submitted.json?limit=50(recent posts). - OAuth (optional): set
Config.BearerTokento talk tooauth.reddit.cominstead — bumps anon 10 req/min to 100 req/min. - No browser fallback needed; Reddit's anonymous JSON endpoints are stable.
ChannelSnapshot |
|
|---|---|
subreddit.subscribers (preferred) or total_karma (fallback) |
Followers |
total_karma |
TotalLikes |
link_karma, comment_karma, awardee_karma, awarder_karma, is_gold, is_mod, created_utc, icon_img, bio |
Raw |
For posts: score → Likes, num_comments → Comments, permalink → URL.
- Reddit requires a unique, descriptive User-Agent. The default UA (
w_popularity/1.0 …) satisfies that. Don't override with a curl-default or you'll get 429s. - Personal-subreddit subscriber count (
u/<user>) is often 0 for users who never opted into the personal-subreddit feature — that's why karma is the fallback. - Anonymous quota: 10 req/min per IP. Use
BearerTokenfor higher limits in production.
import parser "github.com/suenot/reddit-auto"
p := parser.New(parser.Config{})
snap, err := p.FetchChannel(ctx, "suenot")
posts, err := p.FetchRecentPosts(ctx, "suenot", time.Now().AddDate(0, -1, 0))MIT