Base Client
BaseClient
BaseClient(
cookies: Optional[AnyCookieOrHeader] = None,
*,
authkey: Optional[str] = None,
lang: Lang = "en-us",
region: Region = OVERSEAS,
proxy: Optional[str] = None,
game: Optional[Game] = None,
uid: Optional[int] = None,
hoyolab_id: Optional[int] = None,
device_id: Optional[str] = None,
device_fp: Optional[str] = None,
headers: Optional[LooseHeaders] = None,
cache: Optional[BaseCache] = None,
debug: bool = False,
on_cookie_update: Optional[CookieUpdateHook] = None,
)
Base ABC Client.
Methods:
-
genshin_accounts–Get the genshin accounts of the currently logged-in user.
-
get_account_timezone–Get the UTC timezone of the default game account.
-
get_game_accounts–Get the game accounts of the currently logged-in user.
-
request–Make a request and return a parsed json response.
-
request_bbs–Make a request any bbs endpoint.
-
request_hoyolab–Make a request any hoyolab endpoint.
-
request_webstatic–Request a static json file.
-
set_authkey–Set an authkey for wish & transaction logs.
-
set_browser_cookies–Extract cookies from your browser and set them as client cookies.
-
set_cache–Create and set a new cache.
-
set_cookies–Parse and set cookies.
-
set_redis_cache–Create and set a new redis cache.
Attributes:
-
USER_AGENT– -
authkey(Optional[str]) –The default genshin authkey used for paginators.
-
authkeys(dict[Game, str]) – -
cache(BaseCache) – -
cookie_manager(BaseCookieManager) – -
custom_headers(CIMultiDict[str]) – -
debug(bool) –Whether the debug logs are being shown in stdout
-
default_game(Optional[Game]) –The default game.
-
device_fp(Optional[str]) –The device fingerprint used in headers.
-
device_id(Optional[str]) –The device id used in headers.
-
game– -
hoyolab_id(Optional[int]) –The logged-in user's hoyolab uid.
-
lang(str) –The default language, defaults to "en-us"
-
logger(Logger) – -
on_cookie_update(Optional[CookieUpdateHook]) –Callback invoked with a copy of the cookies whenever the client updates them itself.
-
proxy(Optional[str]) –Proxy for http requests.
-
region(Region) –The default region.
-
uid(Optional[int]) –UID of the default game.
-
uids(dict[Game, int]) –
USER_AGENT
class-attribute
instance-attribute
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
hoyolab_id
property
writable
The logged-in user's hoyolab uid.
Returns None if not found or not applicable.
on_cookie_update
property
writable
on_cookie_update: Optional[CookieUpdateHook]
Callback invoked with a copy of the cookies whenever the client updates them itself.
This happens for example when a new cookie_token is minted from an stoken or when a response sets new cookies. May be a sync or async callable. Use it to persist refreshed cookies so the next client created from storage does not need to refresh again.
genshin_accounts
async
genshin_accounts(
*, lang: Optional[str] = None
) -> Sequence[GenshinAccount]
Get the genshin accounts of the currently logged-in user.
get_account_timezone
Get the UTC timezone of the default game account.
get_game_accounts
async
get_game_accounts(
*, lang: Optional[str] = None
) -> Sequence[GenshinAccount]
Get the game accounts of the currently logged-in user.
request
async
request(
url: StrOrURL,
*,
method: Optional[str] = None,
params: Optional[Mapping[str, Any]] = None,
data: Any = None,
headers: Optional[LooseHeaders] = None,
cache: Any = None,
static_cache: Any = None,
**kwargs: Any,
) -> Mapping[str, Any]
Make a request and return a parsed json response.
request_bbs
async
request_bbs(
url: StrOrURL,
*,
lang: Optional[str] = None,
region: Optional[Region] = None,
method: Optional[str] = None,
params: Optional[Mapping[str, Any]] = None,
data: Any = None,
headers: Optional[LooseHeaders] = None,
**kwargs: Any,
) -> Mapping[str, Any]
Make a request any bbs endpoint.
request_hoyolab
async
request_hoyolab(
url: StrOrURL,
*,
lang: Optional[str] = None,
region: Optional[Region] = None,
method: Optional[str] = None,
params: Optional[Mapping[str, Any]] = None,
data: Any = None,
headers: Optional[LooseHeaders] = None,
**kwargs: Any,
) -> Mapping[str, Any]
Make a request any hoyolab endpoint.
request_webstatic
async
request_webstatic(
url: StrOrURL,
*,
headers: Optional[LooseHeaders] = None,
cache: Any = None,
region: Region = OVERSEAS,
**kwargs: Any,
) -> Any
Request a static json file.
set_authkey
Set an authkey for wish & transaction logs.
Accepts an authkey, a url containing an authkey or a path towards a logfile.
set_browser_cookies
Extract cookies from your browser and set them as client cookies.
Available browsers: chrome, chromium, opera, edge, firefox.
set_cache
Create and set a new cache.
set_cookies
Parse and set cookies.