API Reference
client
Classes:
-
YattaAPI–The main class to interact with the Project Yatta API.
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:
-
(langLanguage, default:EN) –The language to use for API responses. Defaults to Language.EN.
-
(cache_ttlint, default:3600) –The time-to-live for the cache in seconds. Defaults to 3600 (1 hour).
-
(headersdict[str, Any] | None, default:None) –Optional dictionary of headers to include in requests.
-
(sessionClientSession | None, default:None) –Optional existing aiohttp.ClientSession to use. If None, a new CachedSession will be created.
-
(cache_backendCacheBackend | None, default:None) –Optional CacheBackend instance for caching. If None, a SQLite backend will be used with a default path.
Methods:
-
close–Close the internal aiohttp session.
-
fetch_book_detail–Fetch detailed information for a specific book.
-
fetch_books–Fetch a list of all available books.
-
fetch_changelogs–Fetch a list of all available changelogs.
-
fetch_character_detail–Fetch detailed information for a specific character.
-
fetch_characters–Fetch a list of all available characters.
-
fetch_item_detail–Fetch detailed information for a specific item.
-
fetch_items–Fetch a list of all available items.
-
fetch_latest_version–Fetch the latest data version hash from the API.
-
fetch_light_cone_detail–Fetch detailed information for a specific light cone.
-
fetch_light_cones–Fetch a list of all available light cones.
-
fetch_manual_avatar–Fetch manual avatar data, typically used for stat mappings.
-
fetch_message_types–Fetch a mapping of message type IDs to their names.
-
fetch_messages–Fetch a list of all available message threads.
-
fetch_relic_set_detail–Fetch detailed information for a specific relic set.
-
fetch_relic_sets–Fetch a list of all available relic sets.
-
start–Initialize the internal aiohttp session.
Attributes:
close
async
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:
-
(idint) –The unique identifier of the book.
-
(use_cachebool, 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:
-
DataNotFoundError–If no book with the given ID is found.
-
YattaAPIError–For other API errors.
fetch_books
async
Fetch a list of all available books.
Parameters:
-
(use_cachebool, default:True) –Whether to allow the response to be served from cache. Defaults to True.
Returns:
Raises:
-
DataNotFoundError–If the book list endpoint returns 404.
-
YattaAPIError–For other API errors.
fetch_changelogs
async
Fetch a list of all available changelogs.
Parameters:
-
(use_cachebool, default:True) –Whether to allow the response to be served from cache. Defaults to True.
Returns:
Raises:
-
DataNotFoundError–If the changelog endpoint returns 404.
-
YattaAPIError–For other API errors.
fetch_character_detail
async
fetch_character_detail(id: int, use_cache: bool = True) -> CharacterDetail
Fetch detailed information for a specific character.
Parameters:
-
(idint) –The unique identifier of the character.
-
(use_cachebool, 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:
-
DataNotFoundError–If no character with the given ID is found.
-
YattaAPIError–For other API errors.
fetch_characters
async
Fetch a list of all available characters.
Parameters:
-
(use_cachebool, default:True) –Whether to allow the response to be served from cache. Defaults to True.
Returns:
Raises:
-
DataNotFoundError–If the character list endpoint returns 404.
-
YattaAPIError–For other API errors.
fetch_item_detail
async
fetch_item_detail(id: int, use_cache: bool = True) -> ItemDetail
Fetch detailed information for a specific item.
Parameters:
-
(idint) –The unique identifier of the item.
-
(use_cachebool, 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:
-
DataNotFoundError–If no item with the given ID is found.
-
YattaAPIError–For other API errors.
fetch_items
async
Fetch a list of all available items.
Parameters:
-
(use_cachebool, default:True) –Whether to allow the response to be served from cache. Defaults to True.
Returns:
Raises:
-
DataNotFoundError–If the item list endpoint returns 404.
-
YattaAPIError–For other API errors.
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:
-
YattaAPIError–For API errors during the fetch.
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:
-
(idint) –The unique identifier of the light cone.
-
(use_cachebool, 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:
-
DataNotFoundError–If no light cone with the given ID is found.
-
YattaAPIError–For other API errors.
fetch_light_cones
async
Fetch a list of all available light cones.
Parameters:
-
(use_cachebool, default:True) –Whether to allow the response to be served from cache. Defaults to True.
Returns:
Raises:
-
DataNotFoundError–If the light cone list endpoint returns 404.
-
YattaAPIError–For other API errors.
fetch_manual_avatar
async
Fetch manual avatar data, typically used for stat mappings.
Parameters:
-
(use_cachebool, 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:
-
DataNotFoundError–If the manual avatar endpoint returns 404.
-
YattaAPIError–For other API errors.
fetch_message_types
async
Fetch a mapping of message type IDs to their names.
Parameters:
-
(use_cachebool, 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:
-
DataNotFoundError–If the message endpoint returns 404.
-
YattaAPIError–For other API errors.
fetch_messages
async
Fetch a list of all available message threads.
Parameters:
-
(use_cachebool, default:True) –Whether to allow the response to be served from cache. Defaults to True.
Returns:
Raises:
-
DataNotFoundError–If the message list endpoint returns 404.
-
YattaAPIError–For other API errors.
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:
-
(idint) –The unique identifier of the relic set.
-
(use_cachebool, 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:
-
DataNotFoundError–If no relic set with the given ID is found.
-
YattaAPIError–For other API errors.
fetch_relic_sets
async
Fetch a list of all available relic sets.
Parameters:
-
(use_cachebool, default:True) –Whether to allow the response to be served from cache. Defaults to True.
Returns:
Raises:
-
DataNotFoundError–If the relic list endpoint returns 404.
-
YattaAPIError–For other API errors.