Skip to content

DDragonClient

from pulsefire.clients import DDragonClient

Bases: BaseClient

Data Dragon Client.

Resources Support
League of Legends ❎ Use CDragon instead.
Teamfight Tactics
Legends of Runeterra
Valorant

Example:

async with DDragonClient(
    default_params={"patch": "latest", "locale": "en_us"}
) as client:
    cards = await client.get_lor_cards(set=8)
    assert cards[0]["cardCode"]

Source code in pulsefire/clients.py
class DDragonClient(BaseClient):
    """Data Dragon Client.

    | Resources            | Support                    |
    | -------------------- | -------------------------- |
    | League of Legends    | ❎ Use CDragon instead.    |
    | Teamfight Tactics    | ❎                         |
    | Legends of Runeterra | ✅                         |
    | Valorant             | ❎                         |

    Example:
    ```python
    async with DDragonClient(
        default_params={"patch": "latest", "locale": "en_us"}
    ) as client:
        cards = await client.get_lor_cards(set=8)
        assert cards[0]["cardCode"]
    ```
    """

    Patch = Literal["latest"] | _str
    Locale = Literal[
        "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://dd.b.pvp.net",
        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_lor_cards(self, *, patch: Patch = ..., locale: Locale = ..., set: str | int = ...) -> list[DDragonSchema.LorCard]:
        return await self.invoke("GET", "/{patch}/set{set}/{locale}/data/set{set}-{locale}.json")
Attributes
Patch class-attribute instance-attribute
Patch = Literal['latest'] | _str
Locale class-attribute instance-attribute
Locale = (
    Literal[
        "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
)
Functions
__init__
__init__(
    *,
    base_url: str = "https://dd.b.pvp.net",
    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
Source code in pulsefire/clients.py
def __init__(
    self,
    *,
    base_url: str = "https://dd.b.pvp.net",
    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
    )
get_lor_cards async
get_lor_cards(
    *, patch: Patch = ..., locale: Locale = ..., set: str | int = ...
) -> list[DDragonSchema.LorCard]
Source code in pulsefire/clients.py
async def get_lor_cards(self, *, patch: Patch = ..., locale: Locale = ..., set: str | int = ...) -> list[DDragonSchema.LorCard]:
    return await self.invoke("GET", "/{patch}/set{set}/{locale}/data/set{set}-{locale}.json")