Collection

class praw.models.Collection(reddit: praw.Reddit, _data: Dict[str, Any] = None, collection_id: Optional[str] = None, permalink: Optional[str] = None)

Class to represent a Collection.

Obtain an instance via:

collection = reddit.subreddit("test").collections("some_uuid")

or

collection = reddit.subreddit("test").collections(
    permalink="https://reddit.com/r/SUBREDDIT/collection/some_uuid"
)

Typical Attributes

Note

This table describes attributes that typically belong to objects of this class. PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit’s end, PRAW makes no effort to document any new/removed/changed attributes, other than to instruct you on how to discover what is available. As a result, this table of attributes may not be complete. See Determine Available Attributes of an Object for detailed information.

If you would like to add an attribute to this table, feel free to open a pull request.

Attribute

Description

author

The Redditor who created the collection.

collection_id

The UUID of the collection.

created_at_utc

Time the collection was created, represented in Unix Time.

description

The collection description.

display_layout

The collection display layout.

last_update_utc

Time the collection was last updated, represented in Unix Time.

link_ids

A list of Submission fullnames.

permalink

The collection’s permalink (to view on the web).

sorted_links

An iterable listing of the posts in this collection.

title

The title of the collection.

__init__(reddit: praw.Reddit, _data: Dict[str, Any] = None, collection_id: Optional[str] = None, permalink: Optional[str] = None)

Initialize a Collection instance.

Parameters
__iter__() Generator[Any, None, None]

Provide a way to iterate over the posts in this Collection.

Example usage:

collection = reddit.subreddit("test").collections("some_uuid")
for submission in collection:
    print(submission.title, submission.permalink)
__len__() int

Get the number of posts in this Collection.

Example usage:

collection = reddit.subreddit("test").collections("some_uuid")
print(len(collection))
follow()

Follow this Collection.

Example usage:

reddit.subreddit("test").collections("some_uuid").follow()

See also

unfollow()

mod() praw.models.reddit.collections.CollectionModeration

Get an instance of CollectionModeration.

Provides access to various methods, including add_post(), delete(), reorder(), and update_title().

Example usage:

collection = reddit.subreddit("test").collections("some_uuid")
collection.mod.update_title("My new title!")
classmethod parse(data: Dict[str, Any], reddit: praw.Reddit) Any

Return an instance of cls from data.

Parameters
  • data – The structured data.

  • reddit – An instance of Reddit.

subreddit() praw.models.Subreddit

Get the subreddit that this collection belongs to.

For example:

collection = reddit.subreddit("test").collections("some_uuid")
subreddit = collection.subreddit
unfollow()

Unfollow this Collection.

Example usage:

reddit.subreddit("test").collections("some_uuid").unfollow()

See also

follow()