psnawp_api.models.trophies.trophy_titles module#
Provides the TrophyTitle class for retrieving overall trophy summary for each video game title.
- class TrophyTitle(np_service_name: str | None, np_communication_id: str | None, trophy_set_version: str | None, title_name: str | None, title_detail: str | None, title_icon_url: str | None, title_platform: frozenset[PlatformType], has_trophy_groups: bool | None, progress: int | None, hidden_flag: bool | None, earned_trophies: TrophySet, defined_trophies: TrophySet, last_updated_datetime: datetime | None, np_title_id: str | None)[source]#
Bases:
objectA class containing summary of trophy data for a user for a game title.
- Variables:
np_service_name (str | None) – trophy for PS3, PS4, or PS Vita platforms and trophy2 for the PS5 platform.
np_communication_id (str | None) – Unique ID of the title.
trophy_set_version (str | None) – The current version of the trophy set.
title_name (str | None) – Title name.
title_detail (str | None) – Title description (PS3, PS4 and PS Vita titles only).
title_icon_url (str | None) – URL of the icon for the title.
title_platform (frozenset[PlatformType]) – Platforms this title belongs to.
has_trophy_groups (bool | None) – True if the title has multiple groups of trophies (eg. DLC trophies which are separate from the main trophy list).
progress (int | None) – Percentage of trophies earned for the title.
hidden_flag (bool | None) – Title has been hidden on the accounts trophy list (Only for Client).
earned_trophies (TrophySet) – Number of trophies for the title which have been earned by type.
defined_trophies (TrophySet) – Number of trophies for the title by type.
last_updated_datetime (datetime.datetime | None) – Date most recent trophy earned for the title (UTC+00:00 TimeZone).
np_title_id (str | None) – Title ID of the title if passed.
- __init__(np_service_name: str | None, np_communication_id: str | None, trophy_set_version: str | None, title_name: str | None, title_detail: str | None, title_icon_url: str | None, title_platform: frozenset[PlatformType], has_trophy_groups: bool | None, progress: int | None, hidden_flag: bool | None, earned_trophies: TrophySet, defined_trophies: TrophySet, last_updated_datetime: datetime | None, np_title_id: str | None) None#
- title_platform: frozenset[PlatformType]#
- class TrophyTitleIterator(authenticator: Authenticator, url: str, pagination_args: PaginationArguments, title_ids: list[str] | None)[source]#
Bases:
PaginationIterator[TrophyTitle]Retrieve all game titles associated with an account, and a summary of trophies earned from them.
- Variables:
title_ids (list[str]) – Optional param that can be passed via init. Lets user fetch Trophy for specific title ids.
Note
This class is intended to be used via Client or User class. See
psnawp_api.models.client.Client.trophy_titles(),psnawp_api.models.client.Client.trophy_titles_for_title(),psnawp_api.models.user.User.trophy_titles(), andpsnawp_api.models.user.User.trophy_titles_for_title().Constructor of TrophyTitles class.
- Parameters:
authenticator – The Authenticator instance used for making authenticated requests to the API.
url – The url of endpoint.
pagination_args – Arguments related to pagination like limit and offset.
- __init__(authenticator: Authenticator, url: str, pagination_args: PaginationArguments, title_ids: list[str] | None) None[source]#
Constructor of TrophyTitles class.
- Parameters:
authenticator – The Authenticator instance used for making authenticated requests to the API.
url – The url of endpoint.
pagination_args – Arguments related to pagination like limit and offset.
- fetch_next_page() Generator[TrophyTitle, None, None][source]#
Fetches the next page in endpoint with pagination.
- classmethod from_endpoint(authenticator: Authenticator, pagination_args: PaginationArguments, account_id: str, title_ids: list[str] | None) Self[source]#
Creates an instance of
TrophyTitleIteratorfrom api endpoint.
- static get_np_communication_id(authenticator: Authenticator, title_id: str, account_id: str) str[source]#
Returns the np communication id of title. This is required for requesting detail about a titles trophies.
Note
The endpoint only returns useful response back if the account has played that particular video game.
- Parameters:
authenticator – The Authenticator instance used for making authenticated requests to the API.
title_id – Unique ID of the title
account_id – Account ID of the user.
- Returns:
np communication id of title
- Raises:
PSNAWPNotFoundError – If the user does not have any trophies for that game or the game doesn’t exist.
- get_trophy_summary_for_title() Generator[TrophyTitle, None, None][source]#
Retrieve a summary of the trophies earned by a user for specific titles.
- Parameters:
- Returns:
Generator object with TitleTrophySummary objects
- Raises:
PSNAWPForbiddenError – If the user’s profile is private
- get_trophy_title() Generator[TrophyTitle, None, None][source]#
Retrieve all game titles associated with an account, and a summary of trophies earned from them.
- Parameters:
limit – Limit of titles returned, None means to return all trophy titles.
- Returns:
Generator object with TitleTrophySummary objects
- Raises:
PSNAWPForbiddenError – If the user’s profile is private