Module genshin.client.components.wiki
Wiki component.
Classes
class WikiClient (cookies: ForwardRef('http.cookies.BaseCookie[Any]') | Mapping[Any, Any] | str | Sequence[ForwardRef('http.cookies.BaseCookie[Any]') | Mapping[Any, Any] | str] | None = None,
*,
authkey: str | None = None,
lang: str = 'en-us',
region: Region = Region.OVERSEAS,
proxy: str | None = None,
game: Game | None = None,
uid: int | None = None,
hoyolab_id: int | None = None,
device_id: str | None = None,
device_fp: str | None = None,
headers: Mapping[str, str] | Mapping[multidict._multidict.istr, str] | multidict._multidict.CIMultiDict | multidict._multidict.CIMultiDictProxy | Iterable[Tuple[str | multidict._multidict.istr, str]] | None = None,
cache: BaseCache | None = None,
debug: bool = False)-
Expand source code
class WikiClient(base.BaseClient): """Wiki component.""" async def request_wiki( self, endpoint: str, *, lang: typing.Optional[str] = None, headers: typing.Optional[typing.Mapping[str, str]] = None, **kwargs: typing.Any, ) -> typing.Mapping[str, typing.Any]: """Make a request towards the wiki endpoint.""" headers = dict(headers or {}) url = routes.WIKI_URL.get_url() / endpoint headers["x-rpc-language"] = lang or self.lang return await self.request(url, headers=headers, **kwargs) @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.CHARACTER], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.CharacterPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.WEAPON], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WeaponPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ARTIFACT], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.ArtifactPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ENEMY], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.EnemyPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: ... async def get_wiki_previews( self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: """Get a list of wiki previews.""" payload = dict(filters=[], menu_id=int(menu), page_num=1, page_size=1000, use_es=True) cache_key = cache.cache_key("wiki", endpoint="entry", menu=menu, lang=lang or self.lang) data = await self.request_wiki("get_entry_page_list", data=payload, lang=lang, static_cache=cache_key) cls = models._ENTRY_PAGE_MODELS.get(typing.cast(models.WikiPageType, menu), models.BaseWikiPreview) return [cls(**i) for i in data["list"] if i["icon_url"]] async def get_wiki_page( self, id: types.IDOr[models.BaseWikiPreview], *, lang: typing.Optional[str] = None, ) -> models.WikiPage: """Get a wiki page.""" params = dict(entry_page_id=int(id)) cache_key = cache.cache_key("wiki", endpoint="page", id=id, lang=lang or self.lang) data = await self.request_wiki("entry_page", lang=lang, params=params, static_cache=cache_key) data["page"].pop("lang", "") # always an empty string return models.WikiPage(**data["page"]) async def get_wiki_pages( self, ids: typing.Collection[types.IDOr[models.BaseWikiPreview]], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WikiPage]: """Get multiple wiki pages without modules.""" payload = dict(entry_page_ids=[int(i) for i in ids]) data = await self.request_wiki("entry_pages", lang=lang, data=payload) return [models.WikiPage(**i) for i in data["entry_pages"]]
Wiki component.
Ancestors
- BaseClient
- abc.ABC
Subclasses
Class variables
var logger : logging.Logger
Instance variables
var authkeys : dict[Game, str]
-
Expand source code
class WikiClient(base.BaseClient): """Wiki component.""" async def request_wiki( self, endpoint: str, *, lang: typing.Optional[str] = None, headers: typing.Optional[typing.Mapping[str, str]] = None, **kwargs: typing.Any, ) -> typing.Mapping[str, typing.Any]: """Make a request towards the wiki endpoint.""" headers = dict(headers or {}) url = routes.WIKI_URL.get_url() / endpoint headers["x-rpc-language"] = lang or self.lang return await self.request(url, headers=headers, **kwargs) @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.CHARACTER], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.CharacterPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.WEAPON], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WeaponPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ARTIFACT], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.ArtifactPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ENEMY], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.EnemyPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: ... async def get_wiki_previews( self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: """Get a list of wiki previews.""" payload = dict(filters=[], menu_id=int(menu), page_num=1, page_size=1000, use_es=True) cache_key = cache.cache_key("wiki", endpoint="entry", menu=menu, lang=lang or self.lang) data = await self.request_wiki("get_entry_page_list", data=payload, lang=lang, static_cache=cache_key) cls = models._ENTRY_PAGE_MODELS.get(typing.cast(models.WikiPageType, menu), models.BaseWikiPreview) return [cls(**i) for i in data["list"] if i["icon_url"]] async def get_wiki_page( self, id: types.IDOr[models.BaseWikiPreview], *, lang: typing.Optional[str] = None, ) -> models.WikiPage: """Get a wiki page.""" params = dict(entry_page_id=int(id)) cache_key = cache.cache_key("wiki", endpoint="page", id=id, lang=lang or self.lang) data = await self.request_wiki("entry_page", lang=lang, params=params, static_cache=cache_key) data["page"].pop("lang", "") # always an empty string return models.WikiPage(**data["page"]) async def get_wiki_pages( self, ids: typing.Collection[types.IDOr[models.BaseWikiPreview]], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WikiPage]: """Get multiple wiki pages without modules.""" payload = dict(entry_page_ids=[int(i) for i in ids]) data = await self.request_wiki("entry_pages", lang=lang, data=payload) return [models.WikiPage(**i) for i in data["entry_pages"]]
var cache : BaseCache
-
Expand source code
class WikiClient(base.BaseClient): """Wiki component.""" async def request_wiki( self, endpoint: str, *, lang: typing.Optional[str] = None, headers: typing.Optional[typing.Mapping[str, str]] = None, **kwargs: typing.Any, ) -> typing.Mapping[str, typing.Any]: """Make a request towards the wiki endpoint.""" headers = dict(headers or {}) url = routes.WIKI_URL.get_url() / endpoint headers["x-rpc-language"] = lang or self.lang return await self.request(url, headers=headers, **kwargs) @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.CHARACTER], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.CharacterPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.WEAPON], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WeaponPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ARTIFACT], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.ArtifactPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ENEMY], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.EnemyPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: ... async def get_wiki_previews( self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: """Get a list of wiki previews.""" payload = dict(filters=[], menu_id=int(menu), page_num=1, page_size=1000, use_es=True) cache_key = cache.cache_key("wiki", endpoint="entry", menu=menu, lang=lang or self.lang) data = await self.request_wiki("get_entry_page_list", data=payload, lang=lang, static_cache=cache_key) cls = models._ENTRY_PAGE_MODELS.get(typing.cast(models.WikiPageType, menu), models.BaseWikiPreview) return [cls(**i) for i in data["list"] if i["icon_url"]] async def get_wiki_page( self, id: types.IDOr[models.BaseWikiPreview], *, lang: typing.Optional[str] = None, ) -> models.WikiPage: """Get a wiki page.""" params = dict(entry_page_id=int(id)) cache_key = cache.cache_key("wiki", endpoint="page", id=id, lang=lang or self.lang) data = await self.request_wiki("entry_page", lang=lang, params=params, static_cache=cache_key) data["page"].pop("lang", "") # always an empty string return models.WikiPage(**data["page"]) async def get_wiki_pages( self, ids: typing.Collection[types.IDOr[models.BaseWikiPreview]], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WikiPage]: """Get multiple wiki pages without modules.""" payload = dict(entry_page_ids=[int(i) for i in ids]) data = await self.request_wiki("entry_pages", lang=lang, data=payload) return [models.WikiPage(**i) for i in data["entry_pages"]]
-
Expand source code
class WikiClient(base.BaseClient): """Wiki component.""" async def request_wiki( self, endpoint: str, *, lang: typing.Optional[str] = None, headers: typing.Optional[typing.Mapping[str, str]] = None, **kwargs: typing.Any, ) -> typing.Mapping[str, typing.Any]: """Make a request towards the wiki endpoint.""" headers = dict(headers or {}) url = routes.WIKI_URL.get_url() / endpoint headers["x-rpc-language"] = lang or self.lang return await self.request(url, headers=headers, **kwargs) @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.CHARACTER], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.CharacterPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.WEAPON], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WeaponPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ARTIFACT], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.ArtifactPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ENEMY], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.EnemyPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: ... async def get_wiki_previews( self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: """Get a list of wiki previews.""" payload = dict(filters=[], menu_id=int(menu), page_num=1, page_size=1000, use_es=True) cache_key = cache.cache_key("wiki", endpoint="entry", menu=menu, lang=lang or self.lang) data = await self.request_wiki("get_entry_page_list", data=payload, lang=lang, static_cache=cache_key) cls = models._ENTRY_PAGE_MODELS.get(typing.cast(models.WikiPageType, menu), models.BaseWikiPreview) return [cls(**i) for i in data["list"] if i["icon_url"]] async def get_wiki_page( self, id: types.IDOr[models.BaseWikiPreview], *, lang: typing.Optional[str] = None, ) -> models.WikiPage: """Get a wiki page.""" params = dict(entry_page_id=int(id)) cache_key = cache.cache_key("wiki", endpoint="page", id=id, lang=lang or self.lang) data = await self.request_wiki("entry_page", lang=lang, params=params, static_cache=cache_key) data["page"].pop("lang", "") # always an empty string return models.WikiPage(**data["page"]) async def get_wiki_pages( self, ids: typing.Collection[types.IDOr[models.BaseWikiPreview]], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WikiPage]: """Get multiple wiki pages without modules.""" payload = dict(entry_page_ids=[int(i) for i in ids]) data = await self.request_wiki("entry_pages", lang=lang, data=payload) return [models.WikiPage(**i) for i in data["entry_pages"]]
var custom_headers : multidict._multidict.CIMultiDict[str]
-
Expand source code
class WikiClient(base.BaseClient): """Wiki component.""" async def request_wiki( self, endpoint: str, *, lang: typing.Optional[str] = None, headers: typing.Optional[typing.Mapping[str, str]] = None, **kwargs: typing.Any, ) -> typing.Mapping[str, typing.Any]: """Make a request towards the wiki endpoint.""" headers = dict(headers or {}) url = routes.WIKI_URL.get_url() / endpoint headers["x-rpc-language"] = lang or self.lang return await self.request(url, headers=headers, **kwargs) @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.CHARACTER], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.CharacterPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.WEAPON], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WeaponPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ARTIFACT], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.ArtifactPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ENEMY], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.EnemyPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: ... async def get_wiki_previews( self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: """Get a list of wiki previews.""" payload = dict(filters=[], menu_id=int(menu), page_num=1, page_size=1000, use_es=True) cache_key = cache.cache_key("wiki", endpoint="entry", menu=menu, lang=lang or self.lang) data = await self.request_wiki("get_entry_page_list", data=payload, lang=lang, static_cache=cache_key) cls = models._ENTRY_PAGE_MODELS.get(typing.cast(models.WikiPageType, menu), models.BaseWikiPreview) return [cls(**i) for i in data["list"] if i["icon_url"]] async def get_wiki_page( self, id: types.IDOr[models.BaseWikiPreview], *, lang: typing.Optional[str] = None, ) -> models.WikiPage: """Get a wiki page.""" params = dict(entry_page_id=int(id)) cache_key = cache.cache_key("wiki", endpoint="page", id=id, lang=lang or self.lang) data = await self.request_wiki("entry_page", lang=lang, params=params, static_cache=cache_key) data["page"].pop("lang", "") # always an empty string return models.WikiPage(**data["page"]) async def get_wiki_pages( self, ids: typing.Collection[types.IDOr[models.BaseWikiPreview]], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WikiPage]: """Get multiple wiki pages without modules.""" payload = dict(entry_page_ids=[int(i) for i in ids]) data = await self.request_wiki("entry_pages", lang=lang, data=payload) return [models.WikiPage(**i) for i in data["entry_pages"]]
var uids : dict[Game, int]
-
Expand source code
class WikiClient(base.BaseClient): """Wiki component.""" async def request_wiki( self, endpoint: str, *, lang: typing.Optional[str] = None, headers: typing.Optional[typing.Mapping[str, str]] = None, **kwargs: typing.Any, ) -> typing.Mapping[str, typing.Any]: """Make a request towards the wiki endpoint.""" headers = dict(headers or {}) url = routes.WIKI_URL.get_url() / endpoint headers["x-rpc-language"] = lang or self.lang return await self.request(url, headers=headers, **kwargs) @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.CHARACTER], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.CharacterPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.WEAPON], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WeaponPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ARTIFACT], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.ArtifactPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: typing.Literal[models.WikiPageType.ENEMY], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.EnemyPreview]: ... @typing.overload async def get_wiki_previews( # noqa: D102 missing docstring in overload? self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: ... async def get_wiki_previews( self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: """Get a list of wiki previews.""" payload = dict(filters=[], menu_id=int(menu), page_num=1, page_size=1000, use_es=True) cache_key = cache.cache_key("wiki", endpoint="entry", menu=menu, lang=lang or self.lang) data = await self.request_wiki("get_entry_page_list", data=payload, lang=lang, static_cache=cache_key) cls = models._ENTRY_PAGE_MODELS.get(typing.cast(models.WikiPageType, menu), models.BaseWikiPreview) return [cls(**i) for i in data["list"] if i["icon_url"]] async def get_wiki_page( self, id: types.IDOr[models.BaseWikiPreview], *, lang: typing.Optional[str] = None, ) -> models.WikiPage: """Get a wiki page.""" params = dict(entry_page_id=int(id)) cache_key = cache.cache_key("wiki", endpoint="page", id=id, lang=lang or self.lang) data = await self.request_wiki("entry_page", lang=lang, params=params, static_cache=cache_key) data["page"].pop("lang", "") # always an empty string return models.WikiPage(**data["page"]) async def get_wiki_pages( self, ids: typing.Collection[types.IDOr[models.BaseWikiPreview]], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WikiPage]: """Get multiple wiki pages without modules.""" payload = dict(entry_page_ids=[int(i) for i in ids]) data = await self.request_wiki("entry_pages", lang=lang, data=payload) return [models.WikiPage(**i) for i in data["entry_pages"]]
Methods
async def get_wiki_page(self,
id: int | genshin.models.genshin.wiki.BaseWikiPreview,
*,
lang: str | None = None) ‑> WikiPage-
Expand source code
async def get_wiki_page( self, id: types.IDOr[models.BaseWikiPreview], *, lang: typing.Optional[str] = None, ) -> models.WikiPage: """Get a wiki page.""" params = dict(entry_page_id=int(id)) cache_key = cache.cache_key("wiki", endpoint="page", id=id, lang=lang or self.lang) data = await self.request_wiki("entry_page", lang=lang, params=params, static_cache=cache_key) data["page"].pop("lang", "") # always an empty string return models.WikiPage(**data["page"])
Get a wiki page.
async def get_wiki_pages(self,
ids: Collection[int | genshin.models.genshin.wiki.BaseWikiPreview],
*,
lang: str | None = None) ‑> Sequence[WikiPage]-
Expand source code
async def get_wiki_pages( self, ids: typing.Collection[types.IDOr[models.BaseWikiPreview]], *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.WikiPage]: """Get multiple wiki pages without modules.""" payload = dict(entry_page_ids=[int(i) for i in ids]) data = await self.request_wiki("entry_pages", lang=lang, data=payload) return [models.WikiPage(**i) for i in data["entry_pages"]]
Get multiple wiki pages without modules.
async def get_wiki_previews(self, menu: int, *, lang: str | None = None) ‑> Sequence[genshin.models.genshin.wiki.BaseWikiPreview]
-
Expand source code
async def get_wiki_previews( self, menu: int, *, lang: typing.Optional[str] = None, ) -> typing.Sequence[models.BaseWikiPreview]: """Get a list of wiki previews.""" payload = dict(filters=[], menu_id=int(menu), page_num=1, page_size=1000, use_es=True) cache_key = cache.cache_key("wiki", endpoint="entry", menu=menu, lang=lang or self.lang) data = await self.request_wiki("get_entry_page_list", data=payload, lang=lang, static_cache=cache_key) cls = models._ENTRY_PAGE_MODELS.get(typing.cast(models.WikiPageType, menu), models.BaseWikiPreview) return [cls(**i) for i in data["list"] if i["icon_url"]]
Get a list of wiki previews.
async def request_wiki(self,
endpoint: str,
*,
lang: str | None = None,
headers: Mapping[str, str] | None = None,
**kwargs: Any) ‑> Mapping[str, Any]-
Expand source code
async def request_wiki( self, endpoint: str, *, lang: typing.Optional[str] = None, headers: typing.Optional[typing.Mapping[str, str]] = None, **kwargs: typing.Any, ) -> typing.Mapping[str, typing.Any]: """Make a request towards the wiki endpoint.""" headers = dict(headers or {}) url = routes.WIKI_URL.get_url() / endpoint headers["x-rpc-language"] = lang or self.lang return await self.request(url, headers=headers, **kwargs)
Make a request towards the wiki endpoint.
Inherited members