Getting Started
Interact with the Enka Network API using the API client classes:
- Genshin Impact:
enka.GenshinClient
- Honkai Star Rail:
enka.HSRClient
- Zenless Zone Zero:
enka.ZZZClient
Fetching Showcase Data
For simplicity, examples will only use GenshinClient
, but the same applies to the other clients.
You can also call the start
and close
methods manually.
import enka
client = enka.GenshinClient()
await client.start()
await client.fetch_showcase(901211014)
await client.close()
Important
When using the client, you must use either the async with
syntax or call start
and close
manually; otherwise, the client won't work and RuntimeError
will be raised.
Fetching Character Builds
Available after v2.1.0
Please read the Enka Network API docs for more information about what character builds are.
import enka
async with enka.GenshinClient() as client:
showcase = await client.fetch_showcase(618285856)
builds = await client.fetch_builds(showcase.owner)
for character_id, build in builds.items():
print(character_id)
print(build.name, build.character.name)
Fetching and Parsing raw Data
Available after v2.1.1
You can let the API wrapper return the raw data from the API, and later on parse it.
import enka
async with enka.GenshinClient() as client:
raw = await client.fetch_showcase(901211014, raw=True)
parsed = client.parse_showcase(raw)
Catching Exceptions
Exception classes are available in the enka.errors
module.
import enka
async with enka.GenshinClient() as client:
try:
await client.fetch_showcase(901211014)
except enka.errors.GameMaintenanceError:
print("Game is in maintenance.")
Examples
You can find more detailed examples in the examples folder.