0
# User Management
1
2
PRAW provides comprehensive user management capabilities including accessing user profiles, managing friends and blocked users, messaging, and working with the current authenticated user's account.
3
4
## Capabilities
5
6
### Redditor Class - User Profiles
7
8
Access and interact with Reddit user profiles and their content.
9
10
```python { .api }
11
class Redditor:
12
def __init__(self, reddit, name: str = None, fullname: str = None): ...
13
14
def message(
15
self,
16
subject: str,
17
message: str,
18
*,
19
from_subreddit = None
20
):
21
"""
22
Send a private message to the user.
23
24
Parameters:
25
- subject: Message subject
26
- message: Message body (markdown supported)
27
- from_subreddit: Send from subreddit instead of user account
28
29
Returns:
30
Message instance
31
"""
32
33
def friend(self):
34
"""Add user to friends list."""
35
36
def unfriend(self):
37
"""Remove user from friends list."""
38
39
def block(self):
40
"""Block the user."""
41
42
def unblock(self):
43
"""Unblock the user."""
44
```
45
46
### Redditor Properties and Data
47
48
Access user profile information and statistics.
49
50
```python { .api }
51
# Basic properties
52
name: str # Username
53
id: str # User ID
54
fullname: str # Reddit fullname (t2_xxxxx)
55
created_utc: float # Account creation timestamp (UTC)
56
57
# Karma and activity
58
comment_karma: int # Comment karma points
59
link_karma: int # Link karma points
60
awardee_karma: int # Karma from receiving awards
61
awarder_karma: int # Karma from giving awards
62
total_karma: int # Total karma (may not be sum of individual karmas)
63
64
# Premium and status
65
is_gold: bool # Whether user has Reddit Premium
66
is_mod: bool # Whether user is a moderator somewhere
67
is_employee: bool # Whether user is Reddit employee
68
has_verified_email: bool # Whether email is verified
69
icon_img: str # Profile icon URL
70
subreddit: dict # User's profile subreddit info
71
72
# Suspension and verification
73
is_suspended: bool # Whether account is suspended
74
suspension_expiration_utc: float # Suspension expiration (if suspended)
75
verified: bool # Whether account is verified
76
```
77
78
### Redditor Content Access
79
80
Access user's submissions, comments, and activity.
81
82
```python { .api }
83
def submissions(self, **kwargs):
84
"""
85
Get user's submissions.
86
87
Parameters:
88
- sort: Sort order ("new", "hot", "top", "controversial")
89
- time_filter: Time period ("all", "day", "week", "month", "year")
90
- limit: Number of submissions (default: 25, max: 100)
91
92
Returns:
93
ListingGenerator of Submission instances
94
"""
95
96
def comments(self, **kwargs):
97
"""
98
Get user's comments.
99
100
Parameters:
101
- sort: Sort order ("new", "hot", "top", "controversial")
102
- time_filter: Time period ("all", "day", "week", "month", "year")
103
- limit: Number of comments (default: 25, max: 100)
104
105
Returns:
106
ListingGenerator of Comment instances
107
"""
108
109
def hot(self, **kwargs):
110
"""Get user's hot submissions and comments."""
111
112
def new(self, **kwargs):
113
"""Get user's newest submissions and comments."""
114
115
def top(self, time_filter: str = "all", **kwargs):
116
"""Get user's top submissions and comments."""
117
118
def controversial(self, time_filter: str = "all", **kwargs):
119
"""Get user's controversial submissions and comments."""
120
121
def upvoted(self, **kwargs):
122
"""
123
Get submissions upvoted by user (requires authentication).
124
125
Returns:
126
ListingGenerator of Submission instances
127
"""
128
129
def downvoted(self, **kwargs):
130
"""
131
Get submissions downvoted by user (requires authentication).
132
133
Returns:
134
ListingGenerator of Submission instances
135
"""
136
137
def gilded(self, **kwargs):
138
"""
139
Get content gilded by user.
140
141
Returns:
142
ListingGenerator of submissions/comments
143
"""
144
145
def gildings(self, **kwargs):
146
"""
147
Get content user has gilded.
148
149
Returns:
150
ListingGenerator of submissions/comments
151
"""
152
153
def hidden(self, **kwargs):
154
"""
155
Get hidden submissions (requires authentication).
156
157
Returns:
158
ListingGenerator of Submission instances
159
"""
160
161
def saved(self, **kwargs):
162
"""
163
Get saved content (requires authentication).
164
165
Returns:
166
ListingGenerator of submissions/comments
167
"""
168
```
169
170
### Redditor Streaming
171
172
Stream new content from a specific user.
173
174
```python { .api }
175
class RedditorStream:
176
"""Real-time redditor content streaming."""
177
178
def submissions(self, **kwargs):
179
"""
180
Stream new submissions from the user.
181
182
Parameters:
183
- pause_after: Pause after this many requests
184
- skip_existing: Skip submissions created before stream start
185
186
Yields:
187
Submission instances
188
"""
189
190
def comments(self, **kwargs):
191
"""
192
Stream new comments from the user.
193
194
Parameters:
195
- pause_after: Pause after this many requests
196
- skip_existing: Skip comments created before stream start
197
198
Yields:
199
Comment instances
200
"""
201
202
stream: RedditorStream # Streaming instance
203
```
204
205
### Moderator Notes for Redditors
206
207
Access moderator notes for users (requires moderation permissions).
208
209
```python { .api }
210
class RedditorModNotes:
211
"""Moderator notes for redditors."""
212
213
def create(
214
self,
215
*,
216
note: str,
217
subreddit = None,
218
thing = None,
219
**kwargs
220
):
221
"""
222
Create moderator note.
223
224
Parameters:
225
- note: Note content
226
- subreddit: Subreddit context
227
- thing: Associated submission/comment
228
"""
229
230
notes: RedditorModNotes # Moderator notes instance
231
```
232
233
### User Class - Current Authenticated User
234
235
Manage the currently authenticated user's account and preferences.
236
237
```python { .api }
238
class User:
239
def __init__(self, reddit): ...
240
241
def me(self):
242
"""
243
Get current user's profile information.
244
245
Returns:
246
Redditor instance representing current user
247
"""
248
249
def karma(self):
250
"""
251
Get detailed karma breakdown by subreddit.
252
253
Returns:
254
Dictionary with karma breakdown
255
"""
256
257
def preferences(self):
258
"""
259
Get user preferences.
260
261
Returns:
262
Dictionary with user preferences
263
"""
264
265
def friends(self):
266
"""
267
Get friends list.
268
269
Returns:
270
List of Redditor instances
271
"""
272
273
def blocked(self):
274
"""
275
Get blocked users list.
276
277
Returns:
278
List of Redditor instances
279
"""
280
281
def contributor_subreddits(self, **kwargs):
282
"""
283
Get subreddits where user is contributor.
284
285
Returns:
286
ListingGenerator of Subreddit instances
287
"""
288
289
def moderator_subreddits(self, **kwargs):
290
"""
291
Get subreddits where user is moderator.
292
293
Returns:
294
ListingGenerator of Subreddit instances
295
"""
296
297
def multireddits(self):
298
"""
299
Get user's multireddits.
300
301
Returns:
302
List of Multireddit instances
303
"""
304
305
def subreddits(self, **kwargs):
306
"""
307
Get user's subreddits (subscribed).
308
309
Returns:
310
ListingGenerator of Subreddit instances
311
"""
312
313
def trophies(self):
314
"""
315
Get user's trophies.
316
317
Returns:
318
TrophyList instance
319
"""
320
```
321
322
### User Preferences Management
323
324
Manage detailed user preferences and account settings.
325
326
```python { .api }
327
def update_preferences(self, **preferences):
328
"""
329
Update user preferences.
330
331
Parameters:
332
- lang: Interface language
333
- over_18: Show NSFW content
334
- search_include_over_18: Include NSFW in search
335
- label_nsfw: Auto-label NSFW
336
- hide_ups: Hide upvote scores
337
- hide_downs: Hide downvote scores
338
- min_comment_score: Minimum comment score to show
339
- min_link_score: Minimum link score to show
340
- num_comments: Default comments to show
341
- num_sites: Default submissions to show
342
- organic: Show promoted content
343
- compress: Compress links
344
- domain_details: Show domain details
345
- email_messages: Email on messages
346
- email_comments: Email on comment replies
347
- email_upvote_comment: Email on comment upvotes
348
- email_upvote_post: Email on post upvotes
349
- enable_default_themes: Use default themes
350
- show_trending: Show trending subreddits
351
- beta: Participate in beta tests
352
- research: Participate in research
353
- live_orangereds: Real-time notifications
354
- highlight_controversial: Highlight controversial
355
- show_stylesheets: Show custom stylesheets
356
- show_link_flair: Show link flair
357
- show_user_flair: Show user flair
358
- show_flair: Show all flair
359
- mark_messages_read: Auto-mark messages read
360
- threaded_messages: Use threaded messages
361
- collapse_read_messages: Collapse read messages
362
- monitor_mentions: Monitor username mentions
363
- send_welcome_messages: Send welcome messages to new users
364
- allow_clicktracking: Allow click tracking
365
- hide_from_robots: Hide from search engines
366
- public_votes: Make votes public
367
- public_server_seconds: Show server processing time
368
- no_profanity: Filter profanity
369
- newwindow: Open links in new window
370
- numsites: Custom number of links per page
371
- media: Auto-expand media
372
- media_preview: Show media previews
373
- nightmode: Use night mode
374
"""
375
```
376
377
### Trophy System
378
379
Access user trophies and achievements.
380
381
```python { .api }
382
class Trophy:
383
"""User trophy/achievement."""
384
385
name: str # Trophy name
386
description: str # Trophy description
387
icon_40: str # 40px icon URL
388
icon_70: str # 70px icon URL
389
award_id: str # Award ID
390
granted_at: float # Grant timestamp (UTC)
391
url: str # Trophy details URL
392
393
class TrophyList:
394
"""Container for user trophies."""
395
396
def __iter__(self):
397
"""Iterate over trophies."""
398
399
def __len__(self):
400
"""Number of trophies."""
401
```
402
403
### Multireddit Management
404
405
Manage user's multireddits (curated subreddit collections).
406
407
```python { .api }
408
class Multireddit:
409
"""User's multireddit collection."""
410
411
def add(self, subreddit):
412
"""Add subreddit to multireddit."""
413
414
def remove(self, subreddit):
415
"""Remove subreddit from multireddit."""
416
417
def update(self, **settings):
418
"""Update multireddit settings."""
419
420
def copy_from(self, multireddit):
421
"""Copy from another multireddit."""
422
423
def rename(self, new_name: str):
424
"""Rename the multireddit."""
425
426
def delete(self):
427
"""Delete the multireddit."""
428
429
class MultiredditHelper:
430
"""Helper for multireddit management."""
431
432
def create(
433
self,
434
display_name: str,
435
subreddits: list,
436
*,
437
description_md: str = None,
438
visibility: str = "private",
439
**kwargs
440
):
441
"""
442
Create new multireddit.
443
444
Parameters:
445
- display_name: Multireddit name
446
- subreddits: List of subreddit names
447
- description_md: Description (markdown)
448
- visibility: "private" or "public"
449
450
Returns:
451
Multireddit instance
452
"""
453
```
454
455
### Redditor Discovery
456
457
Find and search for Reddit users.
458
459
```python { .api }
460
class Redditors:
461
"""Redditor discovery and search."""
462
463
def new(self, **kwargs):
464
"""
465
Get new redditors.
466
467
Returns:
468
ListingGenerator of Redditor instances
469
"""
470
471
def popular(self, **kwargs):
472
"""
473
Get popular redditors.
474
475
Returns:
476
ListingGenerator of Redditor instances
477
"""
478
479
def search(self, query: str, **kwargs):
480
"""
481
Search for redditors.
482
483
Parameters:
484
- query: Search query
485
- limit: Number of results (default: 25, max: 100)
486
487
Returns:
488
ListingGenerator of Redditor instances
489
"""
490
```
491
492
## Usage Examples
493
494
### Working with User Profiles
495
496
```python
497
# Get user by name
498
user = reddit.redditor("username")
499
500
# Access user info
501
print(f"User: {user.name}")
502
print(f"Comment Karma: {user.comment_karma}")
503
print(f"Link Karma: {user.link_karma}")
504
print(f"Account Age: {user.created_utc}")
505
506
# Check if user has Reddit Premium
507
if user.is_gold:
508
print("User has Reddit Premium")
509
510
# Get user's recent submissions
511
for submission in user.submissions.new(limit=10):
512
print(f"Post: {submission.title}")
513
514
# Get user's recent comments
515
for comment in user.comments.new(limit=10):
516
print(f"Comment: {comment.body[:50]}...")
517
```
518
519
### Friend and Block Management
520
521
```python
522
# Add/remove friends
523
user = reddit.redditor("friend_username")
524
user.friend()
525
user.unfriend()
526
527
# Block/unblock users
528
spam_user = reddit.redditor("spam_username")
529
spam_user.block()
530
spam_user.unblock()
531
532
# Get current user's friends and blocked lists
533
my_friends = reddit.user.friends()
534
blocked_users = reddit.user.blocked()
535
536
print(f"Friends: {len(my_friends)}")
537
print(f"Blocked: {len(blocked_users)}")
538
```
539
540
### Messaging Users
541
542
```python
543
# Send private message to user
544
recipient = reddit.redditor("recipient_username")
545
recipient.message(
546
subject="Hello from PRAW",
547
message="This is a test message sent using PRAW!"
548
)
549
550
# Send message from subreddit
551
recipient.message(
552
subject="Mod Message",
553
message="Message from the moderation team.",
554
from_subreddit=reddit.subreddit("mysubreddit")
555
)
556
```
557
558
### Current User Operations
559
560
```python
561
# Get current user info
562
me = reddit.user.me()
563
print(f"Logged in as: {me.name}")
564
565
# Get karma breakdown by subreddit
566
karma_breakdown = reddit.user.karma()
567
for subreddit, karma in karma_breakdown.items():
568
print(f"r/{subreddit}: {karma['comment_karma']} comment, {karma['link_karma']} link")
569
570
# Get user preferences
571
prefs = reddit.user.preferences()
572
print(f"Language: {prefs['lang']}")
573
print(f"NSFW enabled: {prefs['over_18']}")
574
575
# Get moderated subreddits
576
for subreddit in reddit.user.moderator_subreddits():
577
print(f"Moderates: r/{subreddit.display_name}")
578
579
# Get user's trophies
580
trophies = reddit.user.trophies()
581
for trophy in trophies:
582
print(f"Trophy: {trophy.name} - {trophy.description}")
583
```
584
585
### User Content Streaming
586
587
```python
588
# Stream new submissions from user
589
target_user = reddit.redditor("target_username")
590
for submission in target_user.stream.submissions():
591
print(f"New post by {target_user.name}: {submission.title}")
592
593
# Stream new comments from user
594
for comment in target_user.stream.comments():
595
print(f"New comment by {target_user.name}: {comment.body[:100]}...")
596
```
597
598
### User Search and Discovery
599
600
```python
601
# Search for users
602
for user in reddit.redditors.search("python developer", limit=5):
603
print(f"Found user: {user.name}")
604
605
# Get new users
606
for user in reddit.redditors.new(limit=10):
607
print(f"New user: {user.name}")
608
609
# Get popular users
610
for user in reddit.redditors.popular(limit=10):
611
print(f"Popular user: {user.name}")
612
```
613
614
### Multireddit Management
615
616
```python
617
# Create multireddit
618
multi = reddit.multireddit.create(
619
display_name="Tech News",
620
subreddits=["technology", "programming", "Python"],
621
description_md="Technology and programming news",
622
visibility="public"
623
)
624
625
# Add subreddit to existing multireddit
626
multi.add("MachineLearning")
627
628
# Get user's multireddits
629
user_multis = reddit.user.multireddits()
630
for multi in user_multis:
631
print(f"Multireddit: {multi.display_name}")
632
```
633
634
## Types
635
636
```python { .api }
637
class UserSubreddit:
638
"""User's profile subreddit."""
639
640
display_name: str # Profile name
641
title: str # Profile title
642
public_description: str # Profile description
643
icon_img: str # Profile icon URL
644
banner_img: str # Profile banner URL
645
subscribers: int # Profile followers count
646
```