psnawp_api.models.trophies package#

Submodules#

psnawp_api.models.trophies.trophy module#

class Trophy(trophy_set_version: str | None, has_trophy_groups: bool | None, total_items_count: int | None, trophy_id: int | None, trophy_hidden: bool | None, trophy_type: TrophyType | None, trophy_name: str | None, trophy_detail: str | None, trophy_icon_url: str | None, trophy_group_id: str | None, trophy_progress_target_value: int | None, trophy_reward_name: str | None, trophy_reward_img_url: str | None, earned: bool | None, progress: int | None, progress_rate: int | None, progressed_date_time: datetime | None, earned_date_time: datetime | None, trophy_rarity: TrophyRarity | None, trophy_earn_rate: float | None)[source]#

Bases: object

A class that represents a PlayStation Video Game Trophy.

trophy_set_version: str | None#

The current version of the trophy set

has_trophy_groups: bool | None#

True if this title has additional trophy groups

total_items_count: int | None#

Total trophies in the group (or total trophies for the title if all specified)

trophy_id: int | None#

Unique ID for this trophy

trophy_hidden: bool | None#

True if this is a secret trophy (Only for client)

trophy_type: TrophyType | None#

Type of the trophy

trophy_name: str | None#

Name of trophy

trophy_detail: str | None#

Description of the trophy

trophy_icon_url: str | None#

URL for the graphic associated with the trophy

trophy_group_id: str | None#

ID of the trophy group this trophy belongs to

trophy_progress_target_value: int | None#

Trophy progress towards it being unlocked (PS5 Only)

trophy_reward_name: str | None#

Name of the reward earning the trophy grants (PS5 Only)

trophy_reward_img_url: str | None#

URL for the graphic associated with the reward (PS5 Only)

earned: bool | None#

True if this trophy has been earned

progress: int | None#

If the trophy tracks progress towards unlock this is number of steps currently completed (ie. 73/300) (PS5 titles only)

__init__(trophy_set_version: str | None, has_trophy_groups: bool | None, total_items_count: int | None, trophy_id: int | None, trophy_hidden: bool | None, trophy_type: TrophyType | None, trophy_name: str | None, trophy_detail: str | None, trophy_icon_url: str | None, trophy_group_id: str | None, trophy_progress_target_value: int | None, trophy_reward_name: str | None, trophy_reward_img_url: str | None, earned: bool | None, progress: int | None, progress_rate: int | None, progressed_date_time: datetime | None, earned_date_time: datetime | None, trophy_rarity: TrophyRarity | None, trophy_earn_rate: float | None) None#

Method generated by attrs for class Trophy.

progress_rate: int | None#

If the trophy tracks progress towards unlock this is the current percentage complete (PS5 titles only)

progressed_date_time: datetime | None#

If the trophy tracks progress towards unlock, and some progress has been made, then this returns the date progress was last updated. (PS5 titles only)

earned_date_time: datetime | None#

Date trophy was earned

trophy_rarity: TrophyRarity | None#

Rarity of the trophy

trophy_earn_rate: float | None#

Percentage of all users who have earned the trophy

classmethod from_trophy_dict(trophy_dict: dict[str, Any]) Trophy[source]#
classmethod from_trophies_list(trophies_dict: list[dict[str, Any]] | None) list[psnawp_api.models.trophies.trophy.Trophy][source]#
class TrophyBuilder(request_builder: RequestBuilder, np_communication_id: str)[source]#

Bases: object

Class for providing convenient methods to Build Trophy from PlayStation Endpoints

__init__(request_builder: RequestBuilder, np_communication_id: str)[source]#

Constructor for class TrophyBuilder.

Parameters:
  • request_builder (RequestBuilder) – The instance of RequestBuilder. Used to make HTTPRequests.

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

game_trophies(platform: Literal['PS Vita', 'PS3', 'PS4', 'PS5'], trophy_group_id: str, limit: int | None) Iterator[Trophy][source]#

Retrieves the individual trophy detail of a single - or all - trophy groups for a title.

Parameters:
  • platform (Literal) – The platform this title belongs to.

  • trophy_group_id (str) – ID for the trophy group. Each game expansion is represented by a separate ID. all to return all trophies for the title, default for the game itself, and additional groups starting from 001 and so on return expansions trophies.

  • limit (Optional[int]) – Limit of trophies returned, None means to return all trophy titles.

Returns:

Returns the Trophy Generator object with all the information

Return type:

Iterator[Trophy]

Raises:

PSNAWPNotFound if you don’t have any trophies for that game.

earned_game_trophies(account_id: str, platform: Literal['PS Vita', 'PS3', 'PS4', 'PS5'], trophy_group_id: str, limit: int | None) Iterator[Trophy][source]#

Retrieves the earned status individual trophy detail of a single - or all - trophy groups for a title.

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

  • platform (Literal) – The platform this title belongs to.

  • trophy_group_id (str) – ID for the trophy group. Each game expansion is represented by a separate ID. all to return all trophies for the title, default for the game itself, and additional groups starting from 001 and so on return expansions trophies.

  • limit (Optional[int]) – Limit of trophies returned, None means to return all trophy titles.

Returns:

Returns the Trophy Generator object with all the information

Return type:

Iterator[Trophy]

Raises:

PSNAWPNotFound if you don’t have any trophies for that game.

Raises:

PSNAWPForbidden If the user’s profile is private

earned_game_trophies_with_metadata(account_id: str, platform: Literal['PS Vita', 'PS3', 'PS4', 'PS5'], trophy_group_id: str, limit: int | None) Iterator[Trophy][source]#

Retrieves the earned status with metadata of individual trophy detail of a single - or all - trophy groups for a title.

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

  • platform (Literal) – The platform this title belongs to.

  • trophy_group_id (str) – ID for the trophy group. Each game expansion is represented by a separate ID. all to return all trophies for the title, default for the game itself, and additional groups starting from 001 and so on return expansions trophies.

  • limit (Optional[int]) – Limit of trophies returned, None means to return all trophy titles.

Returns:

Returns the Trophy Generator object with all the information

Return type:

Iterator[Trophy]

Raises:

PSNAWPNotFound if you don’t have any trophies for that game.

Raises:

PSNAWPForbidden If the user’s profile is private

psnawp_api.models.trophies.trophy_constants module#

class TrophyType(value)[source]#

Bases: Enum

An enumeration.

BRONZE = 'bronze'#
SILVER = 'silver'#
GOLD = 'gold'#
PLATINUM = 'platinum'#
class PlatformType(value)[source]#

Bases: Enum

An enumeration.

UNKNOWN = 'UNKNOWN'#
PS_VITA = 'PSVITA'#
PS3 = 'PS3'#
PS4 = 'PS4'#
PS5 = 'PS5'#
class TrophyRarity(value)[source]#

Bases: Enum

An enumeration.

ULTRA_RARE = 0#
VERY_RARE = 1#
RARE = 2#
COMMON = 3#
class TrophySet(bronze: int = 0, silver: int = 0, gold: int = 0, platinum: int = 0)[source]#

Bases: object

bronze: int#
silver: int#
gold: int#
platinum: int#
__init__(bronze: int = 0, silver: int = 0, gold: int = 0, platinum: int = 0) None#

Method generated by attrs for class TrophySet.

psnawp_api.models.trophies.trophy_group module#

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, progress: int | None, earned_trophies: TrophySet, last_updated_datetime: str | None)[source]#

Bases: object

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

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

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 | None#

Date most recent trophy earned for the group

__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: str | None) None#

Method generated by attrs for class TrophyGroupSummary.

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: frozenset[psnawp_api.models.trophies.trophy_constants.PlatformType], defined_trophies: TrophySet, trophy_groups: list[psnawp_api.models.trophies.trophy_group.TrophyGroupSummary], hidden_flag: bool | None, progress: int | None, earned_trophies: TrophySet, last_updated_date_time: str | None)[source]#

Bases: object

TrophyGroupsSummary contains trophy count data for all the groups in a game title combined and individual.

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: frozenset[psnawp_api.models.trophies.trophy_constants.PlatformType]#

The platform this title belongs to

defined_trophies: TrophySet#

Total number of trophies for the title by type

__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: frozenset[psnawp_api.models.trophies.trophy_constants.PlatformType], defined_trophies: TrophySet, trophy_groups: list[psnawp_api.models.trophies.trophy_group.TrophyGroupSummary], hidden_flag: bool | None, progress: int | None, earned_trophies: TrophySet, last_updated_date_time: str | None) None#

Method generated by attrs for class TrophyGroupsSummary.

trophy_groups: list[psnawp_api.models.trophies.trophy_group.TrophyGroupSummary]#

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_date_time: datetime | None#

00 TimeZone)

Type:

Date most recent trophy earned for the title (UTC+00

class TrophyGroupsSummaryBuilder(request_builder: RequestBuilder, np_communication_id: str)[source]#

Bases: object

Class for providing convenient method to Build TrophyGroupsSummary from PlayStation Endpoints

__init__(request_builder: RequestBuilder, np_communication_id: str)[source]#
Parameters:
  • request_builder (RequestBuilder) – The instance of RequestBuilder. Used to make HTTPRequests.

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

game_title_trophy_groups_summary(platform: Literal['PS Vita', 'PS3', 'PS4', 'PS5']) TrophyGroupsSummary[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 (Literal) – The platform this title belongs to.

Returns:

TrophyGroupSummary object containing title and title groups trophy information.

Return type:

TrophyGroupsSummary

Raises:

PSNAWPNotFound if you don’t have any trophies for that game.

Raises:

PSNAWPForbidden If the user’s profile is private

user_trophy_groups_summary(account_id: str, platform: Literal['PS Vita', 'PS3', 'PS4', 'PS5']) TrophyGroupsSummary[source]#

Retrieves the earned 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:
  • account_id (str) – The account whose trophy list is being accessed

  • platform (Literal) – The platform this title belongs to.

Returns:

TrophyGroupSummary object containing title and title groups trophy information.

Return type:

TrophyGroupsSummary

Raises:

PSNAWPNotFound if you don’t have any trophies for that game.

Raises:

PSNAWPForbidden If the user’s profile is private

user_trophy_groups_summary_with_metadata(account_id: str, platform: Literal['PS Vita', 'PS3', 'PS4', 'PS5']) TrophyGroupsSummary[source]#

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

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

Parameters:
  • account_id (str) – The account whose trophy list is being accessed

  • platform (Literal) – The platform this title belongs to.

Returns:

TrophyGroupSummary object containing title and title groups trophy information.

Return type:

TrophyGroupsSummary

Raises:

PSNAWPNotFound if you don’t have any trophies for that game.

Raises:

PSNAWPForbidden If the user’s profile is private

psnawp_api.models.trophies.trophy_summary module#

class TrophySummary(account_id: str, trophy_level: int, progress: int, tier: int, earned_trophies: TrophySet)[source]#

Bases: object

Class representing the overall summary of the number of trophies earned by a user.

account_id: str#

The ID of the account being accessed

trophy_level: int#

The overall trophy level

progress: int#

Percentage process towards the next trophy level

__init__(account_id: str, trophy_level: int, progress: int, tier: int, earned_trophies: TrophySet) None#

Method generated by attrs for class TrophySummary.

tier: int#

The tier this trophy level is in

earned_trophies: TrophySet#

Number of trophies which have been earned by type

classmethod from_endpoint(request_builder: RequestBuilder, account_id: str) TrophySummary[source]#

Retrieve an overall summary of the number of trophies earned for a user broken down by

  • type

  • overall trophy level

  • progress towards the next level

  • current tier

Returns:

TrophySummary object with all the information

Return type:

TrophySummary

Raises:

PSNAWPForbidden If the user’s profile is private

psnawp_api.models.trophies.trophy_titles module#

class TrophyTitle(total_items_count: int | None, 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[psnawp_api.models.trophies.trophy_constants.PlatformType], has_trophy_groups: bool | None, progress: int | None, hidden_flag: bool | None, earned_trophies: TrophySet, defined_trophies: TrophySet, last_updated_date_time: str | None, np_title_id: str | None, rarest_trophies: list[psnawp_api.models.trophies.trophy.Trophy] = _Nothing.NOTHING)[source]#

Bases: object

A class containing summary of trophy data for a user for a game title

total_items_count: int | None#

The total number of trophy titles for this account

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[psnawp_api.models.trophies.trophy_constants.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

__init__(total_items_count: int | None, 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[psnawp_api.models.trophies.trophy_constants.PlatformType], has_trophy_groups: bool | None, progress: int | None, hidden_flag: bool | None, earned_trophies: TrophySet, defined_trophies: TrophySet, last_updated_date_time: str | None, np_title_id: str | None, rarest_trophies: list[psnawp_api.models.trophies.trophy.Trophy] = _Nothing.NOTHING) None#

Method generated by attrs for class TrophyTitle.

defined_trophies: TrophySet#

Number of trophies for the title by type

last_updated_date_time: datetime | None#

00 TimeZone)

Type:

Date most recent trophy earned for the title (UTC+00

np_title_id: str | None#

Title ID of the title if passed

rarest_trophies: list[psnawp_api.models.trophies.trophy.Trophy]#

Returns the trophy where earned is true with the lowest trophyEarnedRate

class TrophyTitles(request_builder: RequestBuilder, account_id: str)[source]#

Bases: object

Retrieve all game titles associated with an account, and a summary of trophies earned from them.

__init__(request_builder: RequestBuilder, account_id: str)[source]#

Constructor of TrophyTitles class.

Note

This class is intended to be interfaced with through PSNAWP.

Parameters:
  • request_builder (RequestBuilder) – The instance of RequestBuilder. Used to make HTTPRequests.

  • account_id (str) – The account whose trophy list is being accessed

get_trophy_titles(limit: int | None) Iterator[TrophyTitle][source]#

Retrieve all game titles associated with an account, and a summary of trophies earned from them.

Parameters:

limit (Optional[int]) – Limit of titles returned, None means to return all trophy titles.

Returns:

Generator object with TitleTrophySummary objects

Return type:

Iterator[TrophyTitle]

Raises:

PSNAWPForbidden If the user’s profile is private

get_trophy_summary_for_title(title_ids: list[str]) Iterator[TrophyTitle][source]#

Retrieve a summary of the trophies earned by a user for specific titles.

Parameters:

title_ids (list[str]) – Unique ID of the title

Returns:

Generator object with TitleTrophySummary objects

Return type:

Iterator[TrophyTitle]

Raises:

PSNAWPForbidden If the user’s profile is private

static get_np_communication_id(request_builder: RequestBuilder, 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:
  • request_builder (RequestBuilder) – The instance of RequestBuilder. Used to make HTTPRequests.

  • title_id (str) – Unique ID of the title

  • account_id (str) – Account ID of the user.

Returns:

np communication id of title

Return type:

str

Raises:

PSNAWPNotFound If the user does not have any trophies for that game or the game doesn’t exist.

psnawp_api.models.trophies.utility_functions module#

trophy_type_str_to_enum(trophy_type_str: str | None) TrophyType | None[source]#
trophy_rarity_to_enum(trophy_rarity: int | None) TrophyRarity | None[source]#

Module contents#