Skip to content

Client Parameters

seria edited this page Jul 24, 2024 · 2 revisions

About HakushinAPI

HakushinAPI is the main class that you use to interact with the hakush.in API.
The HakushinAPI class has the following parameters:

Game

Changes the game of the API you are requesting to with this client.

import hakushin

async with hakushin.HakushinAPI(hakushin.Game.HSR) as api:
    await api.fetch_light_cones()

Language

Changes the language of contents returned by the wrapper, such as weapon names, light cone names, etc.
Defaults to English.

import hakushin

async with hakushin.HakushinAPI(hakushin.Language.ZH) as api:
    ...

Headers

Changes the headers when requesting to the Enka Network API, defaults to {"User-Agent": "hakushin-py"}

import hakushin

async with hakushin.HakushinAPI(headers={"User-Agent": "MyDiscordBot-1.0"}) as api:
    ...

Cache Path

The path to the cache SQLite db file, defaults to ./.cache/hakushin/aiohttp-cache.db.

import hakushin

async with hakushin.HakushinAPI(cache_path="cool_cahe.db") as api:
    ...

Cache TTL

The time to live (ttl) in seconds for the cache to be evicted, defaults to 3600 seconds.

import hakushin

async with hakushin.HakushinAPI(cache_ttl=30) as api:
   ...
Clone this wiki locally