Skip to content

API Reference

client

Classes:

  • YattaAPI

    The main class to interact with the Project Yatta API.

CACHE_PATH module-attribute

CACHE_PATH = Path('./.cache/yatta')

YattaAPI

The main class to interact with the Project Yatta API.

Provide asynchronous methods to fetch various game data like characters, light cones, relics, items, etc. Support caching via aiohttp-client-cache.

Parameters:

  • lang

    (Language, default: EN ) –

    The language to use for API responses. Defaults to Language.EN.

  • cache_ttl

    (int, default: 3600 ) –

    The time-to-live for the cache in seconds. Defaults to 3600 (1 hour).

  • headers

    (dict[str, Any] | None, default: None ) –

    Optional dictionary of headers to include in requests.

  • session

    (ClientSession | None, default: None ) –

    Optional existing aiohttp.ClientSession to use. If None, a new CachedSession will be created.

  • cache_backend

    (CacheBackend | None, default: None ) –

    Optional CacheBackend instance for caching. If None, a SQLite backend will be used with a default path.

Methods:

Attributes:

BASE_URL class-attribute instance-attribute

BASE_URL: Final[str] = 'https://sr.yatta.moe/api/v2'

cache_ttl instance-attribute

cache_ttl = cache_ttl

lang instance-attribute

lang = lang

close async

close() -> None

Close the internal aiohttp session.

Should be called to release resources if not using async with.

fetch_book_detail async

fetch_book_detail(id: int, use_cache: bool = True) -> BookDetail

Fetch detailed information for a specific book.

Parameters:

  • id
    (int) –

    The unique identifier of the book.

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

  • BookDetail

    A BookDetail object containing detailed book information.

Raises:

fetch_books async

fetch_books(use_cache: bool = True) -> list[Book]

Fetch a list of all available books.

Parameters:

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

  • list[Book]

    A list of Book objects.

Raises:

fetch_changelogs async

fetch_changelogs(use_cache: bool = True) -> list[Changelog]

Fetch a list of all available changelogs.

Parameters:

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

Raises:

fetch_character_detail async

fetch_character_detail(id: int, use_cache: bool = True) -> CharacterDetail

Fetch detailed information for a specific character.

Parameters:

  • id
    (int) –

    The unique identifier of the character.

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

  • CharacterDetail

    A CharacterDetail object containing detailed character information.

Raises:

fetch_characters async

fetch_characters(use_cache: bool = True) -> list[Character]

Fetch a list of all available characters.

Parameters:

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

Raises:

fetch_item_detail async

fetch_item_detail(id: int, use_cache: bool = True) -> ItemDetail

Fetch detailed information for a specific item.

Parameters:

  • id
    (int) –

    The unique identifier of the item.

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

  • ItemDetail

    An ItemDetail object containing detailed item information.

Raises:

fetch_items async

fetch_items(use_cache: bool = True) -> list[Item]

Fetch a list of all available items.

Parameters:

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

  • list[Item]

    A list of Item objects.

Raises:

fetch_latest_version async

fetch_latest_version() -> str

Fetch the latest data version hash from the API.

This bypasses the regular cache to ensure the absolute latest version is retrieved.

Returns:

  • str

    The latest version hash string.

Raises:

fetch_light_cone_detail async

fetch_light_cone_detail(id: int, use_cache: bool = True) -> LightConeDetail

Fetch detailed information for a specific light cone.

Parameters:

  • id
    (int) –

    The unique identifier of the light cone.

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

  • LightConeDetail

    A LightConeDetail object containing detailed light cone information.

Raises:

fetch_light_cones async

fetch_light_cones(use_cache: bool = True) -> list[LightCone]

Fetch a list of all available light cones.

Parameters:

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

Raises:

fetch_manual_avatar async

fetch_manual_avatar(use_cache: bool = True) -> dict[str, dict[str, str]]

Fetch manual avatar data, typically used for stat mappings.

Parameters:

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

  • dict[str, dict[str, str]]

    A dictionary containing manual avatar data, often mapping stat keys to names and icons.

Raises:

fetch_message_types async

fetch_message_types(use_cache: bool = True) -> dict[str, str]

Fetch a mapping of message type IDs to their names.

Parameters:

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

  • dict[str, str]

    A dictionary where keys are message type IDs (as strings) and values are type names.

Raises:

fetch_messages async

fetch_messages(use_cache: bool = True) -> list[Message]

Fetch a list of all available message threads.

Parameters:

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

Raises:

fetch_relic_set_detail async

fetch_relic_set_detail(id: int, use_cache: bool = True) -> RelicSetDetail

Fetch detailed information for a specific relic set.

Parameters:

  • id
    (int) –

    The unique identifier of the relic set.

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

  • RelicSetDetail

    A RelicSetDetail object containing detailed relic set information.

Raises:

fetch_relic_sets async

fetch_relic_sets(use_cache: bool = True) -> list[RelicSet]

Fetch a list of all available relic sets.

Parameters:

  • use_cache
    (bool, default: True ) –

    Whether to allow the response to be served from cache. Defaults to True.

Returns:

Raises:

start async

start() -> None

Initialize the internal aiohttp session.

Must be called before making any API requests if not using async with.