class CDragonClient(BaseClient):
"""Community Dragon Client.
| Resources | Support |
| -------------------- | -------------------------- |
| League of Legends | ✅ |
| Legends of Runeterra | ❎ Use DDragon instead. |
| Teamfight Tactics | ✅ |
| Valorant | ❎ |
Example:
```python
async with CDragonClient(
default_params={"patch": "latest", "locale": "default"}
) as client:
champion = await client.get_lol_v1_champion(id=777)
assert champion["name"] == "Yone"
```
"""
Patch = Literal["latest", "pbe"] | _str
Locale = Literal[
"default", "ar_ae", "cs_cz", "de_de", "el_gr", "en_au", "en_gb", "en_ph", "en_sg", "en_us",
"es_ar", "es_es", "es_mx", "fr_fr", "hu_hu", "it_it", "ja_jp", "ko_kr", "pl_pl", "pt_br",
"ro_ro", "ru_ru", "th_th", "tr_tr", "vi_vn", "vn_vn", "zh_cn", "zh_my", "zh_tw",
] | _str
def __init__(
self,
*,
base_url: str = "https://raw.communitydragon.org",
default_params: dict[str, Any] = {"patch": ..., "locale": ...},
default_headers: dict[str, str] = {},
default_queries: dict[str, str] = {},
middlewares: list[Middleware] = [
json_response_middleware(),
http_error_middleware(),
],
) -> None:
super().__init__(
base_url=base_url,
default_params=default_params,
default_headers=default_headers,
default_queries=default_queries,
middlewares=middlewares
)
async def get_lol_champion_bin(self, *, patch: Patch = ..., key_lower: str = ...) -> dict[str, CDragonSchema.LolChampionBinValue]:
return await self.invoke("GET", "/{patch}/game/data/characters/{key_lower}/{key_lower}.bin.json")
async def get_lol_v1_champion(self, *, patch: Patch = ..., locale: Locale = ..., id: int = ...) -> CDragonSchema.LolV1Champion:
return await self.invoke("GET", "/{patch}/plugins/rcp-be-lol-game-data/global/{locale}/v1/champions/{id}.json")
async def get_lol_v1_champion_summary(self, *, patch: Patch = ..., locale: Locale = ...) -> list[CDragonSchema.LolV1ChampionInfo]:
return await self.invoke("GET", "/{patch}/plugins/rcp-be-lol-game-data/global/{locale}/v1/champion-summary.json")
async def get_lol_v1_items(self, *, patch: Patch = ..., locale: Locale = ...) -> list[CDragonSchema.LolV1Item]:
return await self.invoke("GET", "/{patch}/plugins/rcp-be-lol-game-data/global/{locale}/v1/items.json")
async def get_lol_v1_perks(self, *, patch: Patch = ..., locale: Locale = ...) -> list[CDragonSchema.LolV1Perk]:
return await self.invoke("GET", "/{patch}/plugins/rcp-be-lol-game-data/global/{locale}/v1/perks.json")
async def get_lol_v1_summoner_spells(self, *, patch: Patch = ..., locale: Locale = ...) -> list[CDragonSchema.LolV1SummonerSpell]:
return await self.invoke("GET", "/{patch}/plugins/rcp-be-lol-game-data/global/{locale}/v1/summoner-spells.json")
async def get_lol_v1_profile_icons(self, *, patch: Patch = ..., locale: Locale = ...) -> list[CDragonSchema.LolV1ProfileIcon]:
return await self.invoke("GET", "/{patch}/plugins/rcp-be-lol-game-data/global/{locale}/v1/profile-icons.json")
async def get_tft_data(self, *, patch: Patch = ..., locale: Locale = ...) -> CDragonSchema.TftData:
return await self.invoke("GET", "/{patch}/cdragon/tft/{locale}.json")