WikiPage

class asyncpraw.models.reddit.wikipage.WikiPage(reddit: asyncpraw.Reddit, subreddit: asyncpraw.models.Subreddit, name: str, revision: Optional[str] = None, _data: Optional[Dict[str, Any]] = None)

An individual WikiPage object.

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

content_html

The contents of the wiki page, as HTML.

content_md

The contents of the wiki page, as Markdown.

may_revise

A bool representing whether or not the authenticated user may edit the wiki page.

name

The name of the wiki page.

revision_by

The Redditor who authored this revision of the wiki page.

revision_date

The time of this revision, in Unix Time.

subreddit

The Subreddit this wiki page belongs to.

__init__(reddit: asyncpraw.Reddit, subreddit: asyncpraw.models.Subreddit, name: str, revision: Optional[str] = None, _data: Optional[Dict[str, Any]] = None)

Initialize a WikiPage instance.

Parameters

revision – A specific revision ID to fetch. By default, fetches the most recent revision.

discussions(**generator_kwargs: Any) AsyncIterator[asyncpraw.models.Submission]

Return a ListingGenerator for discussions of a wiki page.

Discussions are site-wide links to a wiki page.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To view the titles of discussions of the page "praw_test" in r/test, try:

subreddit = await reddit.subreddit("test")
wikipage = await subreddit.get_page("praw_test")
async for submission in wikipage.discussions():
    print(submission.title)
await edit(content: str, reason: Optional[str] = None, **other_settings: Any)

Edit this WikiPage’s contents.

Parameters
  • content – The updated Markdown content of the page.

  • reason – The reason for the revision.

  • other_settings – Additional keyword arguments to pass.

For example, to replace the first wiki page of r/test with the phrase "test wiki page":

subreddit = await reddit.subreddit("test")
page = await subreddit.wiki.get_page("test", fetch=False)
await page.edit(content="test wiki page")
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() WikiPageModeration

Provide an instance of WikiPageModeration.

For example, to add spez as an editor on the wikipage praw_test try:

subreddit = await reddit.subreddit("test")
page = await subreddit.wiki.get_page("praw_test", fetch=False)
await page.mod.add("spez")
classmethod parse(data: Dict[str, Any], reddit: asyncpraw.Reddit) Any

Return an instance of cls from data.

Parameters
  • data – The structured data.

  • reddit – An instance of Reddit.

await revision(revision: str)

Return a specific version of this page by revision ID.

To view revision "1234abc" of "praw_test" in r/test:

subreddit = await reddit.subreddit("test")
page = await subreddit.wiki.get_page("praw_test", fetch=False)
revision = await page.revision("1234abc")
revisions(**generator_kwargs: Union[str, int, Dict[str, str]]) AsyncGenerator[WikiPage, None]

Return a ListingGenerator for page revisions.

Additional keyword arguments are passed in the initialization of ListingGenerator.

To view the wiki revisions for "praw_test" in r/test try:

subreddit = await reddit.subreddit("test")
page = await subreddit.wiki.get_page("test_page", fetch=False)
async for item in page.revisions():
    print(item)

To get WikiPage objects for each revision:

subreddit = await reddit.subreddit("test")
page = await subreddit.wiki.get_page("test_page", fetch=False)
async for item in page.revisions():
    print(item["page"])