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
- async page(page: str) apraw.models.subreddit.wiki.SubredditWikipage¶
Retrieve a specific
SubredditWikipageby 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
- revisions(*args, **kwargs)¶
Returns an instance of
ListingGeneratormapped to recent wikipage revisions.Note
This listing can be streamed doing the following:
for comment in subreddit.wiki.stream(): print(comment)
- Parameters
kwargs (**Dict) –
ListingGeneratorkwargs.- Returns
generator – A
ListingGeneratormapped to recent wikipage revisions.- Return type
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
aPRAWBaseclass and may vary depending on the status of the response and expected objects.Attribute
Description
content_htmlThe content’s of the wikipage as an HTML string.
content_mdThe content’s of the wikipage formatted as a markdown string.
may_reviseboolnameThe wikipage’s name.
reasonThe reason text for the wikipage’s current revision.
revision_byThe author of the wikipage’s current revision.
revision_dateThe date on which the current revision was made.
revision_idThe 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
res –
Trueif 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
res –
Trueif 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
res –
Trueif 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
WikipageRevisionor its ID string.- Returns
res –
Trueif 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
WikipageRevisionor its ID string.- Returns
res –
Trueif the request was successful, otherwise the response’s raw data.- Return type
bool or Any
- revisions(*args, **kwargs)¶
Returns an instance of
ListingGeneratormapped 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) –
ListingGeneratorkwargs.- Returns
generator – A
ListingGeneratormapped to fetch specific wikipage revisions.- Return type
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
aPRAWBaseclass and may vary depending on the status of the response and expected objects.Attribute
Description
timestampA timestamp of when the revision was made.
pageThe name of the page the revision addresses.
revision_hiddenWhether the revision has been hidden by the editors.
reasonThe reason string for this revision if available.
idThe ID of this revision.