psnawp_api.models.trophies.trophy_group module#

Provides the TrophyGroupsSummary class for retrieving trophy summary for main game and each expansion in the video game title.

class TrophyGroupSummary(trophy_group_id: str | None, trophy_group_name: str | None, trophy_group_detail: str | None, trophy_group_icon_url: str | None, defined_trophies: TrophySet)[source]#

Bases: object

TrophyGroupSummary contains trophy count data for one trophy group of a game title.

Variables:
  • trophy_group_id (str | None) – ID for the trophy group (all titles have default, additional groups are 001 incrementing).

  • trophy_group_name (str | None) – Trophy group name.

  • trophy_group_detail (str | None) – Trophy group description (PS3, PS4 and PS Vita titles only).

  • trophy_group_icon_url (str | None) – URL of the icon for the trophy group.

  • defined_trophies (TrophySet) – Number of trophies for the trophy group by type.

Note

To initialize this class, use the class method TrophyGroupSummary.from_dict().

__init__(trophy_group_id: str | None, trophy_group_name: str | None, trophy_group_detail: str | None, trophy_group_icon_url: str | None, defined_trophies: TrophySet) None#
defined_trophies: TrophySet#
classmethod from_dict(trophy_group_dict: dict[str, Any]) Self[source]#

Creates an instance of TrophyGroupSummary from a dictionary.

Parameters:

data – Dictionary containing data, typically from an API response.

Returns:

A new instance of TrophyGroupSummary.

Expected keys vary by class but generally map to instance attributes. Missing keys may default to None or reasonable defaults.

trophy_group_detail: str | None#
trophy_group_icon_url: str | None#
trophy_group_id: str | None#
trophy_group_name: str | None#
class TrophyGroupSummaryWithProgress(trophy_group_id: str | None, trophy_group_name: str | None, trophy_group_detail: str | None, trophy_group_icon_url: str | None, defined_trophies: TrophySet, progress: int | None, earned_trophies: TrophySet, last_updated_datetime: datetime | None)[source]#

Bases: TrophyGroupSummary

TrophyGroupSummaryWithProgress contains trophy count data for one trophy group of a game title and user progress for each trophy group.

Variables:
  • progress (int | None) – Percentage of trophies earned for group.

  • earned_trophies (TrophySet) – Number of trophies for the group which have been earned by type.

  • last_updated_datetime (datetime.datetime | None) – Date most recent trophy earned for the group.

Note

To initialize this class, use the class method TrophyGroupSummaryWithProgress.from_dict().

__init__(trophy_group_id: str | None, trophy_group_name: str | None, trophy_group_detail: str | None, trophy_group_icon_url: str | None, defined_trophies: TrophySet, progress: int | None, earned_trophies: TrophySet, last_updated_datetime: datetime | None) None#
earned_trophies: TrophySet#
classmethod from_dict(trophy_group_dict: dict[str, Any]) Self[source]#

Creates an instance of TrophyGroupSummaryWithProgress from a dictionary.

Parameters:

data – Dictionary containing data, typically from an API response.

Returns:

A new instance of TrophyGroupSummaryWithProgress.

Expected keys vary by class but generally map to instance attributes. Missing keys may default to None or reasonable defaults.

last_updated_datetime: datetime | None#
progress: int | None#
class TrophyGroupsSummary(trophy_set_version: str | None, trophy_title_name: str | None, trophy_title_detail: str | None, trophy_title_icon_url: str | None, trophy_title_platform: set[PlatformType], defined_trophies: TrophySet, trophy_groups: list[T], hidden_flag: bool | None, progress: int | None, earned_trophies: TrophySet, last_updated_datetime: datetime | None)[source]#

Bases: Generic[T]

Summary of trophy data for a PlayStation game title.

This class encapsulates the trophy summary information returned by the PlayStation API. It provides overall trophy counts for a game title as well as detailed summaries for each trophy group. A trophy group represents a segment of the title such as the main game or any associated DLCs/expansions. For example, if a game has two DLCs, the trophy_groups list will include three entries: one for the main game and one for each DLC.

Variables:
  • trophy_set_version (str | None) – The current version of the trophy set.

  • trophy_title_name (str | None) – Title name.

  • trophy_title_detail (str | None) – Title description (PS3, PS4 and PS Vita titles only).

  • trophy_title_icon_url (str | None) – URL of the icon for the trophy title.

  • trophy_title_platform (set[PlatformType]) – The platform this title belongs to.

  • defined_trophies (TrophySet) – Total number of trophies for the title by type.

  • trophy_groups (list[T]) – Individual object for each trophy group returned.

  • hidden_flag (bool | None) – Whether title has been hidden on the accounts trophy list (Authenticating account only).

  • progress (int | None) – Percentage of trophies earned for the title.

  • earned_trophies (TrophySet) – Number of trophies for the title which have been earned by type.

  • last_updated_datetime (datetime.datetime | None) – Date most recent trophy earned for the title (UTC+00:00 TimeZone).

Initialize a TrophyGroupsSummary instance with PlayStation trophy data.

__init__(trophy_set_version: str | None, trophy_title_name: str | None, trophy_title_detail: str | None, trophy_title_icon_url: str | None, trophy_title_platform: set[PlatformType], defined_trophies: TrophySet, trophy_groups: list[T], hidden_flag: bool | None, progress: int | None, earned_trophies: TrophySet, last_updated_datetime: datetime | None) None[source]#

Initialize a TrophyGroupsSummary instance with PlayStation trophy data.

class TrophyGroupsSummaryBuilder(authenticator: Authenticator, np_communication_id: str)[source]#

Bases: object

Provides methods to build a TrophyGroupsSummary from PlayStation Network endpoints.

Variables:
  • authenticator (Authenticator) – An instance of Authenticator used to authenticate and make HTTPS requests.

  • np_communication_id (str) – Unique identifier associated with a game’s trophy set, essential for accessing trophy data.

Note

This class is intended to be used via Client or User class. See psnawp_api.models.client.Client.trophy_groups_summary() or psnawp_api.models.user.User.trophy_groups_summary().

Initializes the TrophyGroupsSummaryBuilder.

Parameters:
  • authenticator (Authenticator) – Instance used to make HTTP requests.

  • np_communication_id (str) – Unique ID of a game title used to request trophy information. This can be obtained from the GameTitle class.

__init__(authenticator: Authenticator, np_communication_id: str) None[source]#

Initializes the TrophyGroupsSummaryBuilder.

Parameters:
  • authenticator (Authenticator) – Instance used to make HTTP requests.

  • np_communication_id (str) – Unique ID of a game title used to request trophy information. This can be obtained from the GameTitle class.

earned_user_trophy_groups_summary(account_id: str, platform: PlatformType) TrophyGroupsSummary[TrophyGroupSummaryWithProgress][source]#

Retrieves the earned trophy groups for a title and their respective trophy count along with their trophy earned progress.

This is most commonly seen in games which have expansions where additional trophies are added.

Warning

Retrieving the progress of TrophyGroupSummary will require double the number of request because the progress has to be fetched via separate endpoint.

Parameters:
  • account_id – The account whose trophy list is being accessed.

  • platform – The platform this title belongs to.

Returns:

TrophyGroupSummary object containing title and title groups trophy information.

Raises:
game_title_trophy_groups_summary(platform: PlatformType) TrophyGroupsSummary[TrophyGroupSummary][source]#

Retrieves the trophy groups for a title and their respective trophy count.

This is most commonly seen in games which have expansions where additional trophies are added.

Parameters:

platform – The platform this title belongs to.

Returns:

TrophyGroupSummary object containing title and title groups trophy information.

Raises:
np_communication_id: str#
static trophy_groups_dict_to_obj(trophy_groups_dict: dict[str, Any], trophy_groups: list[T]) TrophyGroupsSummary[T][source]#

Takes list of TrophyGroupSummary and TrophyGroupSummaryWithProgress converts them to Class instance.

Parameters:
  • trophy_groups_dict – dict from endpoint.

  • trophy_groups – list of TrophyGroupSummary or TrophyGroupSummaryWithProgress

Returns:

TrophyGroupsSummary containing list of TrophyGroupSummary or TrophyGroupSummaryWithProgress along with some more information.