psnawp_api.models.trophies package

Submodules

psnawp_api.models.trophies.trophy module

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

Bases: object

A class that represents a PlayStation Video Game Trophy.

trophy_set_version: Optional[str]

The current version of the trophy set

has_trophy_groups: Optional[bool]

True if this title has additional trophy groups

total_items_count: Optional[int]

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

trophy_id: Optional[int]

Unique ID for this trophy

trophy_hidden: Optional[bool]

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

trophy_type: Optional[TrophyType]

Type of the trophy

trophy_name: Optional[str]

Name of trophy

trophy_detail: Optional[str]

Description of the trophy

trophy_icon_url: Optional[str]

URL for the graphic associated with the trophy

trophy_group_id: Optional[str]

ID of the trophy group this trophy belongs to

trophy_progress_target_value: Optional[int]

Trophy progress towards it being unlocked (PS5 Only)

trophy_reward_name: Optional[str]

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

trophy_reward_img_url: Optional[str]

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

earned: Optional[bool]

True if this trophy has been earned

progress: Optional[int]

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

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

Method generated by attrs for class Trophy.

progress_rate: Optional[int]

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

progressed_date_time: Optional[datetime]

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: Optional[datetime]

Date trophy was earned

trophy_rarity: Optional[TrophyRarity]

Rarity of the trophy

trophy_earn_rate: Optional[float]

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: Optional[list[dict[str, Any]]]) 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: Optional[int]) 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: Optional[int]) 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: Optional[int]) 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: Optional[str], trophy_group_name: Optional[str], trophy_group_detail: Optional[str], trophy_group_icon_url: Optional[str], defined_trophies: TrophySet, progress: Optional[int], earned_trophies: TrophySet, last_updated_datetime: Optional[str])[source]

Bases: object

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

trophy_group_id: Optional[str]

ID for the trophy group (all titles have default, additional groups are 001 incrementing)

trophy_group_name: Optional[str]

Trophy group name

trophy_group_detail: Optional[str]

Trophy group description (PS3, PS4 and PS Vita titles only)

trophy_group_icon_url: Optional[str]

URL of the icon for the trophy group

defined_trophies: TrophySet

Number of trophies for the trophy group by type

progress: Optional[int]

Percentage of trophies earned for group

earned_trophies: TrophySet

Number of trophies for the group which have been earned by type

last_updated_datetime: Optional[datetime]

Date most recent trophy earned for the group

__init__(trophy_group_id: Optional[str], trophy_group_name: Optional[str], trophy_group_detail: Optional[str], trophy_group_icon_url: Optional[str], defined_trophies: TrophySet, progress: Optional[int], earned_trophies: TrophySet, last_updated_datetime: Optional[str]) None

Method generated by attrs for class TrophyGroupSummary.

class TrophyGroupsSummary(trophy_set_version: Optional[str], trophy_title_name: Optional[str], trophy_title_detail: Optional[str], trophy_title_icon_url: Optional[str], trophy_title_platform: PlatformType, defined_trophies: TrophySet, trophy_groups: list[psnawp_api.models.trophies.trophy_group.TrophyGroupSummary], hidden_flag: Optional[bool], progress: Optional[int], earned_trophies: TrophySet, last_updated_date_time: Optional[str])[source]

Bases: object

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

trophy_set_version: Optional[str]

The current version of the trophy set

trophy_title_name: Optional[str]

Title name

trophy_title_detail: Optional[str]

Title description (PS3, PS4 and PS Vita titles only)

trophy_title_icon_url: Optional[str]

URL of the icon for the trophy title

trophy_title_platform: PlatformType

The platform this title belongs to

defined_trophies: TrophySet

Total number of trophies for the title by type

__init__(trophy_set_version: Optional[str], trophy_title_name: Optional[str], trophy_title_detail: Optional[str], trophy_title_icon_url: Optional[str], trophy_title_platform: PlatformType, defined_trophies: TrophySet, trophy_groups: list[psnawp_api.models.trophies.trophy_group.TrophyGroupSummary], hidden_flag: Optional[bool], progress: Optional[int], earned_trophies: TrophySet, last_updated_date_time: Optional[str]) 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: Optional[bool]

Whether title has been hidden on the accounts trophy list (Authenticating account only)

progress: Optional[int]

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: Optional[datetime]

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

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: Optional[int], np_service_name: Optional[str], np_communication_id: Optional[str], trophy_set_version: Optional[str], title_name: Optional[str], title_detail: Optional[str], title_icon_url: Optional[str], title_platform: frozenset[psnawp_api.models.trophies.trophy_constants.PlatformType], has_trophy_groups: Optional[bool], progress: Optional[int], hidden_flag: Optional[bool], earned_trophies: TrophySet, defined_trophies: TrophySet, last_updated_date_time: Optional[str], rarest_trophies: list[psnawp_api.models.trophies.trophy.Trophy] = NOTHING)[source]

Bases: object

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

total_items_count: Optional[int]

The total number of trophy titles for this account

np_service_name: Optional[str]

trophy for PS3, PS4, or PS Vita platforms and trophy2 for the PS5 platform

np_communication_id: Optional[str]

Unique ID of the title

trophy_set_version: Optional[str]

The current version of the trophy set

title_name: Optional[str]

Title name

title_detail: Optional[str]

Title description (PS3, PS4 and PS Vita titles only)

title_icon_url: Optional[str]

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: Optional[bool]

True if the title has multiple groups of trophies (eg. DLC trophies which are separate from the main trophy list)

progress: Optional[int]

Percentage of trophies earned for the title

hidden_flag: Optional[bool]

Title has been hidden on the accounts trophy list (Only for Client)

__init__(total_items_count: Optional[int], np_service_name: Optional[str], np_communication_id: Optional[str], trophy_set_version: Optional[str], title_name: Optional[str], title_detail: Optional[str], title_icon_url: Optional[str], title_platform: frozenset[psnawp_api.models.trophies.trophy_constants.PlatformType], has_trophy_groups: Optional[bool], progress: Optional[int], hidden_flag: Optional[bool], earned_trophies: TrophySet, defined_trophies: TrophySet, last_updated_date_time: Optional[str], rarest_trophies: list[psnawp_api.models.trophies.trophy.Trophy] = NOTHING) None

Method generated by attrs for class TrophyTitle.

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_date_time: Optional[datetime]

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

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: Optional[int]) 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: Optional[str]) Optional[TrophyType][source]
trophy_rarity_to_enum(trophy_rarity: Optional[int]) Optional[TrophyRarity][source]

Module contents