reddit.inbox

class praw.models.Inbox(reddit, _data)

Inbox is a Listing class that represents the inbox.

Parameters:
__init__(reddit, _data)

Initialize a PRAWBase instance.

Parameters:
Return type:

None

all(**generator_kwargs)

Return a ListingGenerator for all inbox comments and messages.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To output the type and ID of all items available via this listing do:

for item in reddit.inbox.all(limit=None):
    print(repr(item))
Return type:

Iterator[Message | Comment]

Parameters:

generator_kwargs (str | int | dict[str, str])

collapse(items)

Mark an inbox message as collapsed.

Parameters:

items (list[Message]) – A list containing instances of Message.

Return type:

None

Requests are batched at 25 items (reddit limit).

For example, to collapse all unread Messages, try:

from praw.models import Message

unread_messages = []
for item in reddit.inbox.unread(limit=None):
    if isinstance(item, Message):
        unread_messages.append(item)
reddit.inbox.collapse(unread_messages)
comment_replies(**generator_kwargs)

Return a ListingGenerator for comment replies.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To output the author of one request worth of comment replies try:

for reply in reddit.inbox.comment_replies():
    print(reply.author)
Return type:

Iterator[Comment]

Parameters:

generator_kwargs (str | int | dict[str, str])

mark_all_read()

Mark all messages as read with just one API call.

Example usage:

reddit.inbox.mark_all_read()

Note

This method returns after Reddit acknowledges your request, instead of after the request has been fulfilled.

Return type:

None

mark_read(items)

Mark Comments or Messages as read.

Parameters:

items (list[Comment | Message]) – A list containing instances of Comment and/or Message to be marked as read relative to the authorized user’s inbox.

Return type:

None

Requests are batched at 25 items (reddit limit).

For example, to mark all unread Messages as read, try:

from praw.models import Message

unread_messages = []
for item in reddit.inbox.unread(limit=None):
    if isinstance(item, Message):
        unread_messages.append(item)
reddit.inbox.mark_read(unread_messages)
mark_unread(items)

Unmark Comments or Messages as read.

Parameters:

items (list[Comment | Message]) – A list containing instances of Comment and/or Message to be marked as unread relative to the authorized user’s inbox.

Return type:

None

Requests are batched at 25 items (Reddit limit).

For example, to mark the first 10 items as unread try:

to_unread = list(reddit.inbox.all(limit=10))
reddit.inbox.mark_unread(to_unread)
mentions(**generator_kwargs)

Return a ListingGenerator for mentions.

A mention is Comment in which the authorized redditor is named in its body like u/spez.

Additional keyword arguments are passed in the initialization of ListingGenerator.

For example, to output the author and body of the first 25 mentions try:

for mention in reddit.inbox.mentions(limit=25):
    print(f"{mention.author}\\n{mention.body}\\n")
Return type:

Iterator[Comment]

Parameters:

generator_kwargs (str | int | dict[str, str])

message(message_id)

Return a Message corresponding to message_id.

Parameters:

message_id (str) – The base36 ID of a message.

Return type:

Message

For example:

message = reddit.inbox.message("7bnlgu")
messages(**generator_kwargs)

Return a ListingGenerator for inbox messages.

Additional keyword arguments are passed in the initialization of ListingGenerator.

For example, to output the subject of the most recent 5 messages try:

for message in reddit.inbox.messages(limit=5):
    print(message.subject)
Return type:

Iterator[Message]

Parameters:

generator_kwargs (str | int | dict[str, str])

classmethod parse(data, reddit)

Return an instance of cls from data.

Parameters:
Return type:

PRAWBase

sent(**generator_kwargs)

Return a ListingGenerator for sent messages.

Additional keyword arguments are passed in the initialization of ListingGenerator.

For example, to output the recipient of the most recent 15 messages try:

for message in reddit.inbox.sent(limit=15):
    print(message.dest)
Return type:

Iterator[Message]

Parameters:

generator_kwargs (str | int | dict[str, str])

stream(**stream_options)

Yield new inbox items as they become available.

Items are yielded oldest first. Up to 100 historical items will initially be returned.

Keyword arguments are passed to stream_generator().

For example, to retrieve all new inbox items, try:

for item in reddit.inbox.stream():
    print(item)
Return type:

Iterator[Comment | Message]

Parameters:

stream_options (str | int | dict[str, str])

submission_replies(**generator_kwargs)

Return a ListingGenerator for submission replies.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To output the author of one request worth of submission replies try:

for reply in reddit.inbox.submission_replies():
    print(reply.author)
Return type:

Iterator[Comment]

Parameters:

generator_kwargs (str | int | dict[str, str])

uncollapse(items)

Mark an inbox message as uncollapsed.

Parameters:

items (list[Message]) – A list containing instances of Message.

Return type:

None

Requests are batched at 25 items (reddit limit).

For example, to uncollapse all unread Messages, try:

from praw.models import Message

unread_messages = []
for item in reddit.inbox.unread(limit=None):
    if isinstance(item, Message):
        unread_messages.append(item)
reddit.inbox.uncollapse(unread_messages)
unread(*, mark_read=False, **generator_kwargs)

Return a ListingGenerator for unread comments and messages.

Parameters:
  • mark_read (bool) – Marks the inbox as read (default: False).

  • generator_kwargs (str | int | dict[str, str] | None)

Return type:

Iterator[Comment | Message]

Note

This only marks the inbox as read not the messages. Use Inbox.mark_read() to mark the messages.

Additional keyword arguments are passed in the initialization of ListingGenerator.

For example, to output the author of unread comments try:

from praw.models import Comment

for item in reddit.inbox.unread(limit=None):
    if isinstance(item, Comment):
        print(item.author)