Collection¶
- class asyncpraw.models.Collection(reddit: asyncpraw.Reddit, _data: Dict[str, Any] = None, collection_id: Optional[str] = None, permalink: Optional[str] = None)¶
Class to represent a Collection.
Obtain an instance via:
subreddit = await reddit.subreddit("SUBREDDIT") collection = await subreddit.collections("some_uuid")
or
subreddit = await reddit.subreddit("SUBREDDIT") collection = await subreddit.collections( permalink="https://reddit.com/r/SUBREDDIT/collection/some_uuid" )
Typical Attributes
This table describes attributes that typically belong to objects of this class. Since attributes are dynamically provided (see Determine Available Attributes of an Object), there is not a guarantee that these attributes will always be present, nor that they will be the only attributes present.
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.
last_update_utc
Time the collection was last updated, represented in Unix Time.
link_ids
A
list
ofSubmission
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: Optional[str] = None, permalink: Optional[str] = None)¶
Initialize this collection.
- Parameters
reddit – An instance of
Reddit
._data – Any data associated with the Collection (optional).
collection_id – The ID of the Collection (optional).
permalink – The permalink of the Collection (optional).
- for ... in __iter__() Generator[Any, None, None] ¶
Provide a way to iterate over the posts in this Collection.
Example usage:
subreddit = await reddit.subreddit("SUBREDDIT") 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("SUBREDDIT") collection = await subreddit.collections("some_uuid") print(len(collection))
- await follow()¶
Follow this Collection.
Example usage:
subreddit = await reddit.subreddit("SUBREDDIT") 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() asyncpraw.models.reddit.collections.CollectionModeration ¶
Get an instance of
CollectionModeration
.Provides access to various methods, including
add_post()
,delete()
,reorder()
, andupdate_title()
.Example usage:
subreddit = await reddit.subreddit("SUBREDDIT") collection = await subreddit.collections("some_uuid") await collection.mod.update_title("My new title!")
- classmethod parse(data: Dict[str, Any], reddit: asyncpraw.Reddit) Any ¶
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("SUBREDDIT") collection = await subreddit.collections("some_uuid") print(await collection.subreddit())
Note
This list of attributes is not complete. Async PRAW dynamically provides the attributes that Reddit returns via the API. Because those attributes are subject to change on Reddit’s end, Async PRAW makes no effort to document them, other than to instruct you on how to discover what is available. See Determine Available Attributes of an Object for detailed information.