Subreddit Wiki

This section details the usage of models related to subreddit wiki.

SubredditWiki

class apraw.models.SubredditWiki(reddit: Reddit, subreddit: Subreddit)

A helper class to aid in retrieving subreddit wiki pages, revisions as well as creating items.

async __call__() List[str]

Retrieve a list of the available wikipages.

Returns

pages – A list of all the wikipages in the subreddit by name.

Return type

List[str]

async create(page: str, content_md: str = '', reason: str = '') apraw.models.subreddit.wiki.SubredditWikipage

Create a new wikipage on the subreddit.

Parameters
  • page (str) – The wikipage’s name.

  • content_md (str) – The wikipage’s content as a markdown string.

  • reason (str) – An optional string detailing the reason for the creation of this wikipage.

Returns

wikipage – The newly created wikipage.

Return type

SubredditWikipage

async page(page: str) apraw.models.subreddit.wiki.SubredditWikipage

Retrieve a specific SubredditWikipage by its name.

Parameters

page (str) – The wikipage’s name which can be retrieved using the list from __call__().

Returns

wikipage – The requested wikipage if it exists.

Return type

SubredditWikipage

revisions(*args, **kwargs)

Returns an instance of ListingGenerator mapped to recent wikipage revisions.

Note

This listing can be streamed doing the following:

for comment in subreddit.wiki.stream():
    print(comment)
Parameters

kwargs (**Dict) – ListingGenerator kwargs.

Returns

generator – A ListingGenerator mapped to recent wikipage revisions.

Return type

ListingGenerator

SubredditWikipage

class apraw.models.SubredditWikipage(name: str, reddit: Reddit, subreddit: Subreddit, data: Dict = None)

The model that represents Subreddit wikipages.

Typical Attributes

This table describes attributes that typically belong to objects of this class. Attributes are dynamically provided by the aPRAWBase class and may vary depending on the status of the response and expected objects.

Attribute

Description

content_html

The content’s of the wikipage as an HTML string.

content_md

The content’s of the wikipage formatted as a markdown string.

may_revise

bool

name

The wikipage’s name.

reason

The reason text for the wikipage’s current revision.

revision_by

The author of the wikipage’s current revision.

revision_date

The date on which the current revision was made.

revision_id

The ID of the wikipage’s current revision.

async add_editor(username: str) Union[bool, Any]

Add a Redditor to the editors of this wikipage.

Parameters

username (str) – The Redditor’s username without the prefix.

Returns

resTrue if the request was successful, otherwise the response’s raw data.

Return type

bool or Any

async del_editor(username: str) Union[bool, Any]

Remove a Redditor from the editors of this wikipage.

Parameters

username (str) – The Redditor’s username without the prefix.

Returns

resTrue if the request was successful, otherwise the response’s raw data.

Return type

bool or Any

async edit(content_md: str, reason: Optional[str] = '') Union[bool, Any]

Edit a wikipage’s markdown contents.

Parameters
  • content_md (str) – The new wikipage’s content as a markdown string.

  • reason (Optional[str]) – An optional reason for this edit.

Returns

resTrue if the request was successful, otherwise the response’s raw data.

Return type

bool or Any

async hide(revision: Union[str, apraw.models.subreddit.wiki.WikipageRevision])

Hide a wikipage revision from the public history.

Parameters

revision (str or WikipageRevision) – The wikipage revision either as a WikipageRevision or its ID string.

Returns

resTrue if the request was successful, otherwise the response’s raw data.

Return type

bool or Any

async revert(revision: Union[str, apraw.models.subreddit.wiki.WikipageRevision]) Union[bool, Any]

Revert a wikipage to its previous revision.

Parameters

revision (str or WikipageRevision) – The wikipage revision either as a WikipageRevision or its ID string.

Returns

resTrue if the request was successful, otherwise the response’s raw data.

Return type

bool or Any

revisions(*args, **kwargs)

Returns an instance of ListingGenerator mapped to fetch specific wikipage revisions.

Note

This listing can be streamed doing the following:

for comment in subreddit.wiki.page("test").stream():
    print(comment)
Parameters

kwargs (**Dict) – ListingGenerator kwargs.

Returns

generator – A ListingGenerator mapped to fetch specific wikipage revisions.

Return type

ListingGenerator

WikipageRevision

class apraw.models.WikipageRevision(reddit: Reddit, data: Dict = None)

The model that represents wikipage revisions.

author: Redditor

The Redditor that made this revision.

Typical Attributes

This table describes attributes that typically belong to objects of this class. Attributes are dynamically provided by the aPRAWBase class and may vary depending on the status of the response and expected objects.

Attribute

Description

timestamp

A timestamp of when the revision was made.

page

The name of the page the revision addresses.

revision_hidden

Whether the revision has been hidden by the editors.

reason

The reason string for this revision if available.

id

The ID of this revision.