Collection¶
- class asyncpraw.models.Collection(reddit, _data=None, collection_id=None, permalink=None)¶
Class to represent a
Collection.Obtain an instance via:
subreddit = await reddit.subreddit("test") collection = await subreddit.collections("some_uuid")
or
subreddit = await reddit.subreddit("test") collection = await subreddit.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. Async PRAW dynamically provides the attributes that Reddit returns via the API. Since those attributes are subject to change on Reddit’s end, Async 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 (asyncpraw.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:
subreddit = await reddit.subreddit("test") collection = await subreddit.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:
subreddit = await reddit.subreddit("test") collection = await subreddit.collections("some_uuid") print(len(collection))
- Return type:
- property created_datetime: datetime¶
Return the creation time as a timezone-aware
datetime.datetime.The returned object is localized to the system’s timezone.
- await follow()¶
Follow this
Collection.Example usage:
subreddit = await reddit.subreddit("test") collection = await subreddit.collections("some_uuid") await collection.follow()
See also
- Return type:
- await load()¶
Re-fetches the object.
This is used to explicitly fetch or re-fetch the object from reddit. This method can be used on any
RedditBaseobject.await reddit_base_object.load()
- Return type:
- mod()¶
Get an instance of
CollectionModeration.Provides access to various methods, including
add_post(),delete(),reorder(), andupdate_title().Example usage:
subreddit = await reddit.subreddit("test") collection = await subreddit.collections("some_uuid") await collection.mod.update_title("My new title!")
- Return type:
- classmethod parse(data, reddit)¶
Return an instance of
clsfromdata.
- await subreddit()¶
Get the subreddit that this collection belongs to.
For example:
subreddit = await reddit.subreddit("test") collection = await subreddit.collections("some_uuid") print(await collection.subreddit())
- Return type:
- await unfollow()¶
Unfollow this
Collection.Example usage:
subreddit = await reddit.subreddit("test") collection = await subreddit.collections("some_uuid") await collection.unfollow()
See also
- Return type:
- property updated_datetime: datetime¶
Return the last update time as a timezone-aware
datetime.datetime.The returned object is localized to the system’s timezone.