Hillcow
Hillcow

Reputation: 969

Get Reddit usernames of users who use a specific subreddit

I would like to generate a list of usernames of users who use a specific subreddit.

As far as I know, it is not possible to simply get a list of users who subscribed to the subreddit. If that's not possible, it would probably be the best to go through all threads and look at who has commented.

How would I approach this?

Upvotes: 6

Views: 14575

Answers (1)

justcool393
justcool393

Reputation: 247

It is not possible to get a list of subscribers. You can use Pushshift's API to get a list of all known commenters in a specific subreddit using the /reddit/comment/search?subreddit=srhere endpoint, although you might want to use PSAW for that.

Given a reddit instance r, here's how to get it using PRAW only:

srname = 'subreddit_name_here'
users = []
sr = r.subreddit(srname)
for comment in sr.comments(limit=1000):
     a = comment.author
     if not a in users:
         users.append(a)

Upvotes: 7

Related Questions