Collection¶
- class asyncpraw.models.Collection(reddit: asyncpraw.Reddit, _data: dict[str, Any] = None, collection_id: str | None = None, permalink: str | None = 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
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: asyncpraw.Reddit, _data: dict[str, Any] = None, collection_id: str | None = None, permalink: str | None = None)¶
Initialize a
Collection
instance.- Parameters:
reddit – An instance of
Reddit
._data – Any data associated with the
Collection
.collection_id – The ID of the
Collection
.permalink – The permalink of the
Collection
.
- for ... in __iter__() Iterator[Any, None, None] ¶
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)
- __len__() int ¶
Get the number of posts in this
Collection
.Example usage:
subreddit = await reddit.subreddit("test") collection = await subreddit.collections("some_uuid") print(len(collection))
- await follow()¶
Follow this
Collection
.Example usage:
subreddit = await reddit.subreddit("test") collection = await subreddit.collections("some_uuid") await collection.follow()
See also
- 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
RedditBase
object.await reddit_base_object.load()
- mod() CollectionModeration ¶
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!")
- classmethod parse(data: dict[str, Any], reddit: asyncpraw.Reddit) AsyncPRAWBase ¶
Return an instance of
cls
fromdata
.- Parameters:
data – The structured data.
reddit – An instance of
Reddit
.
- await subreddit() asyncpraw.models.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())
- await unfollow()¶
Unfollow this
Collection
.Example usage:
subreddit = await reddit.subreddit("test") collection = await subreddit.collections("some_uuid") await collection.unfollow()
See also