Skip to content
Back to top
View this page

# SubredditCollections

class praw.models.reddit.collections.SubredditCollections(reddit: praw.Reddit, subreddit: praw.models.Subreddit, _data: Dict[str, Any] | None = None)

  Class to represent a `Subreddit`’s `Collection`s.

  Obtain an instance via:

      reddit.subreddit("test").collections

  __call__(collection_id: str | None = None, permalink: str | None = None)

    Return the `Collection` with the specified ID.

    Parameters:

      - collection_id – The ID of a `Collection` (default: `None`).

      - permalink – The permalink of a collection (default: `None`).

    Returns:

      The specified `Collection`.

    Exactly one of `collection_id` or `permalink` is required.

    Example usage:

        subreddit = reddit.subreddit("test")

        uuid = "847e4548-a3b5-4ad7-afb4-edbfc2ed0a6b"
        collection = subreddit.collections(uuid)
        print(collection.title)
        print(collection.description)

        permalink = "https://www.reddit.com/r/SUBREDDIT/collection/" + uuid
        collection = subreddit.collections(permalink=permalink)
        print(collection.title)
        print(collection.description)

  __init__(reddit: praw.Reddit, subreddit: praw.models.Subreddit, _data: Dict[str, Any] | None = None)

    Initialize a `SubredditCollections` instance.

  __iter__()

    Iterate over the `Subreddit`’s `Collection`s.

    Example usage:

        for collection in reddit.subreddit("test").collections:
            print(collection.permalink)

  mod() → SubredditCollectionsModeration

    Get an instance of `SubredditCollectionsModeration`.

    Provides `create()`:

        my_sub = reddit.subreddit("test")
        new_collection = my_sub.collections.mod.create(title="Title", description="desc")

  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`.