Collection¶
- class praw.models.Collection(reddit, _data=None, collection_id=None, permalink=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/test/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
authorThe
Redditorwho created the collection.collection_idThe UUID of the collection.
created_at_utcTime the collection was created, represented in Unix Time.
descriptionThe collection description.
display_layoutThe collection display layout.
last_update_utcTime the collection was last updated, represented in Unix Time.
link_idsA list of
Submissionfullnames.permalinkThe collection’s permalink (to view on the web).
sorted_linksAn iterable listing of the posts in this collection.
titleThe title of the collection.
- Parameters:
reddit (praw.Reddit)
collection_id (str | None)
permalink (str | None)
- __init__(reddit, _data=None, collection_id=None, permalink=None)¶
Initialize a
Collectioninstance.- Parameters:
_data (
dict[str,Any] |None) – Any data associated with theCollection.collection_id (
str|None) – The ID of theCollection.permalink (
str|None) – The permalink of theCollection.
- Return type:
None
- __iter__()¶
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)
- Return type:
- __len__()¶
Get the number of posts in this
Collection.Example usage:
collection = reddit.subreddit("test").collections("some_uuid") print(len(collection))
- Return type:
- follow()¶
Follow this
Collection.Example usage:
reddit.subreddit("test").collections("some_uuid").follow()
See also
- Return type:
- mod()¶
Get an instance of
CollectionModeration.Provides access to various methods, including
add_post(),delete(),reorder(), andupdate_title().Example usage:
collection = reddit.subreddit("test").collections("some_uuid") collection.mod.update_title("My new title!")
- Return type:
- classmethod parse(data, reddit)¶
Return an instance of
clsfromdata.
- subreddit()¶
Get the subreddit that this collection belongs to.
For example:
collection = reddit.subreddit("test").collections("some_uuid") subreddit = collection.subreddit
- Return type:
- unfollow()¶
Unfollow this
Collection.Example usage:
reddit.subreddit("test").collections("some_uuid").unfollow()
See also
- Return type: