fandom package

Module functions

fandom.search(query: str, wiki: str = '', language: str = '', results: int = 10)

Do a fandom search.

The search returns a list of tuples, with the page title and the page id.

Parameters
  • query (str) – What to search for

  • wiki (str) – The wiki to search in (defaults to the global wiki variable)

  • language (str) – The language to search in (defaults to the global language variable)

  • results (int) – The maximum number of results to be returned

Returns

list of tuple

fandom.summary(title: str, wiki: str = '', language: str = '', sentences: int = - 1, redirect: bool = True)

Plain text summary of the page with the requested title. Is just an implementation of FandomPage.summary, but with the added functionality of requesting a specific amount of sentences.

Parameters
  • title (str) – The title of the page to get the summary of

  • wiki (str) – The wiki to search (defaults to the global wiki variable. If the global wiki variable is not set, defaults to “runescape”)

  • language (str) – The language to search in (defaults to the global language variable. If the global language variable is not set, defaults to english)

  • sentences (int) – The maximum number of sentences to output. Defaults to the whole summary

  • redirect (bool) – Allow redirection without raising RedirectError

fandom.page(title: str = '', pageid: int = - 1, wiki: str = '', language: str = '', redirect: bool = True, preload: bool = False)

Get a FandomPage object for the page in the sub fandom with title or the pageid (mutually exclusive).

Parameters
  • title (str) –

    • the title of the page to load

  • pageid (int) – The numeric pageid of the page to load

  • wiki (str) – The wiki to search (defaults to the global wiki variable. If the global wiki variable is not set, defaults to “runescape”)

  • language (str) – The language to search in (defaults to the global language variable. If the global language variable is not set, defaults to english)

  • redirect (bool) – Allow redirection without raising RedirectError

  • preload (bool) – Load content, summary, images, references, and links during initialization

fandom.random(pages: int = 1, wiki: str = '', language: str = '')

Get a list of random fandom article titles.

Returns the results as tuples with the title and page id.

Note

Random only gets articles from namespace 0, meaning only articles

Parameters
  • pages (int) – the number of random pages returned (max of 10)

  • wiki (str) – The wiki to search (defaults to the global wiki variable. If the global wiki variable is not set, defaults to “runescape”)

  • language (str) – The language to search in (defaults to the global language variable. If the global language variable is not set, defaults to english)

Returns

tuple if the pages parameter was 1, list of tuple if it was larger

fandom.set_lang(language: str)

Sets the global language variable

Parameters

language (str) – The language to set as the global language variable

fandom.set_rate_limiting(rate_limit: bool, min_wait: int = 50)

Enable or disable rate limiting on requests to the fandom servers. If rate limiting is not enabled, under some circumstances (depending on load on fandom, the number of requests you and other fandom users are making, and other factors), fandom may return an HTTP timeout error.

Note

Enabling rate limiting generally prevents that issue, but please note that HTTPTimeoutError still might be raised.

Parameters
  • rate_limit (bool) – Whether to enable rate limiting or not

  • min_wait (int) – If rate limiting is enabled, min_wait is the minimum time to wait before requests in milliseconds.

fandom.set_user_agent(user_agent_string: str)

Set the User-Agent string to be used for all requests.

Parameters

user_agent_string (str) – A string specifying the User-Agent header

fandom.set_wiki(wiki: str)

Sets the global wiki variable

Parameters

wiki (str) – The wiki to set as the global wiki variable