psnawp_api.models.user module#
Provides Class User representing a PlayStation User account.
- class User(authenticator: Authenticator, online_id: str, account_id: str)[source]#
Bases:
objectClass containing the information about the PSN ID you passed in when creating object.
Note
This class is intended to be used via PSNAWP. See
psnawp_api.psnawp.PSNAWP.user()Constructor of Class User.
- Parameters:
authenticator – The Authenticator instance used for making authenticated requests to the API.
online_id – Online ID (GamerTag) of the user.
account_id – Account ID of the user.
- __init__(authenticator: Authenticator, online_id: str, account_id: str) None[source]#
Constructor of Class User.
- Parameters:
authenticator – The Authenticator instance used for making authenticated requests to the API.
online_id – Online ID (GamerTag) of the user.
account_id – Account ID of the user.
- friends_list(limit: int = 1000) Generator[User, None, None][source]#
Gets the friends list and returns an iterator of User objects.
- Parameters:
limit – The number of items from input max is 1000.
- Returns:
All friends in your friends list.
- Raises:
PSNAWPForbiddenError – When the user’s when you don’t have permission to view their friends list.
user_example = psnawp.user(online_id="VaultTec_Trading") friends_list = user_example.friends_list() for friend in friends_list: ...
- friendship() dict[str, Any][source]#
Gets the friendship status and stats of the user.
- Returns:
A dict containing info similar to what is shown below
{ "friendRelation": "friend", "personalDetailSharing": "none", "friendsCount": 419, "mutualFriendsCount": 0 }
user_example = psnawp.user(online_id="VaultTec_Trading") print(user_example.friendship())
- classmethod from_account_id(authenticator: Authenticator, account_id: str) Self[source]#
Creates the User instance from account ID and returns the instance.
- Parameters:
request_builder – Used to call http requests.
account_id – Account ID of the user.
- Returns:
User Class object which represents a PlayStation account
- Raises:
PSNAWPNotFoundError – If the user is not valid/found.
- classmethod from_online_id(authenticator: Authenticator, online_id: str) Self[source]#
Creates the User instance from online ID and returns the instance.
- Parameters:
authenticator – The Authenticator instance used for making authenticated requests to the API.
online_id – Online ID (GamerTag) of the user.
- Returns:
User Class object which represents a PlayStation account
- Raises:
PSNAWPNotFoundError – If the user is not valid/found.
- get_presence() dict[str, Any][source]#
Gets the presences of a user.
- Returns:
A dict containing info similar to what is shown below:
{ "basicPresence": { "availability": "availableToPlay", "gameTitleInfoList": [ { "format": "PS4", "gameStatus": "Surviving on the server: Chasm HM [Monthly]", "launchPlatform": "PS5", "npTitleIconUrl": "http://gs2-sec.ww.prod.dl.playstation.net/gs2-sec/appkgo/prod/CUSA14296_00/5/i_2a5430eced065f2c08f1beec578f3990d4dbcba726e70653ac98baf88d73a7f9/i/icon0.png", "npTitleId": "CUSA14296_00", "titleName": "Rust" } ], "primaryPlatformInfo": { "onlineStatus": "online", "platform": "PS5" } } }
- Raises:
PSNAWPForbiddenError – When the user’s profile is private, and you don’t have permission to view their online status.
user_example = psnawp.user(online_id="VaultTec_Trading") print(user_example.get_presence())
- get_profile_legacy() dict[str, Any][source]#
Gets the user profile info from legacy api endpoint. Useful for legacy console (PS3, PS4) presence.
- Returns:
A dict containing info similar to what is shown below:
{ "profile": { "onlineId": "VaultTec_Trading", "accountId": "8520698476712646544", "npId": "VmF1bHRUZWNfVHJhZGluZ0BiNi51cw==", "avatarUrls": [ { "size": "l", "avatarUrl": "[Redacted]" } ], "plus": 0, "aboutMe": "r/Fallout76Marketplace Moderator", "languagesUsed": [ "en" ], "trophySummary": { "level": 1, "progress": 0, "earnedTrophies": { "platinum": 0, "gold": 0, "silver": 0, "bronze": 0 } }, "isOfficiallyVerified": false, "personalDetail": { "firstName": "VaultTec", "lastName": "TradingCo", "profilePictureUrls": [ { "size": "xl", "profilePictureUrl": "[Redacted]" } ] }, "personalDetailSharing": "no", "personalDetailSharingRequestMessageFlag": false, "primaryOnlineStatus": "offline", "presences": [ { "onlineStatus": "offline", "hasBroadcastData": false, "lastOnlineDate": "2021-02-05T20:14:45Z" } ], "friendRelation": "no", "requestMessageFlag": false, "blocking": false, "following": false, "consoleAvailability": { "availabilityStatus": "offline" } } }
user_example = psnawp.user(online_id="VaultTec_Trading") print(user_example.get_profile_legacy())
- get_region() Country | None[source]#
Gets the region of the user.
- Returns:
Returns Country object from Pycountry of the User or None if not found.
user_example = psnawp.user(online_id="VaultTec_Trading") print(user_example.get_region())
Note
See pycountry/pycountry for more info on Country object.
Gets the shareable link and QR code for the PlayStation profile.
This method fetches the URL that can be used to easily share the user’s PlayStation profile. Additionally, it provides a QR code image URL that corresponds to the shareable URL.
- Returns:
A dict containing info similar to what is shown below:
{ "shareUrl": "https://profile.playstation.com/VaultTec-Co", "shareImageUrl": "https://d18lxmvkmz0olj.cloudfront.net/profile-VaultTec-Co?Expires=1738389804&Signature=rpk9Ycblv96cT~qYe0LZgOntA1S88k0rW4vRTUgJOFwk3RyqeBWxM7rXXkUIrwtmKsWSxrP~zSG34w0bHYpeQHZRyA6AQtyMcVMSLTBBYyyYZohSKIEMFlNo5aXnjyEM587uWXzn69eqF4QOIig546hqWweFuva89UfbdbZhJLiff50-lYtOiQE1jWEjjBsYA2q6zG-psaA-VnvB1v48c35avbaK5mDk0qDfKAVpPg79-ziOYwLg~pykcqUW02Fu8MRn65m67qxUqzn3hBzNyPb6NGLmmBiqE-39HYRAOYxeAKWcYf4NW3DA265DNHWAMWVI~dh96mhrAA5e8-mAQQ__&Key-Pair-Id=K2SHBT8E7OQNQU", "shareImageUrlDestination": "https://profile.playstation.com/share/VaultTec-Co" }
user_example = psnawp.user(online_id="VaultTec_Trading") print(user_example.get_shareable_profile_link())
- is_blocked() bool[source]#
Checks if the user is blocked by you.
- Returns:
True if the user is blocked otherwise False
user_example = psnawp.user(online_id="VaultTec_Trading") print(user_example.is_blocked())
- profile() dict[str, Any][source]#
Gets the profile of the user such as about me, avatars, languages etc…
- Returns:
A dict containing info similar to what is shown below:
{ "onlineId": "VaultTec-Co", "aboutMe": "r/Fallout76Marketplace Moderator", "avatars": [ { "size": "s", "url": "[Redacted]" }, { "size": "xl", "url": "[Redacted]" }, { "size": "l", "url": "[Redacted]" }, { "size": "m", "url": "[Redacted]" } ], "languages": [ "en-US" ], "isPlus": false, "isOfficiallyVerified": false, "isMe": false }
user_example = psnawp.user(online_id="VaultTec_Trading") print(user_example.profile())
- title_stats(*, limit: int | None = None, offset: int = 0, page_size: int = 200) TitleStatsIterator[source]#
Retrieve a list of titles with their stats and basic meta-data.
- Parameters:
limit – Limit of titles returned.
page_size – The number of items to receive per api request.
offset – Specifies the offset for paginator.
Warning
Only returns data for PS4 games and above.
- Returns:
Iterator class for TitleStats
user_example = psnawp.user(online_id="jeranther") for title in user_example.title_stats(): ...
- trophies(np_communication_id: str, platform: PlatformType, include_progress: Literal[False] = False, trophy_group_id: str = 'default', limit: int | None = None, offset: int = 0, page_size: int = 200) TrophyIterator[source]#
- trophies(np_communication_id: str, platform: PlatformType, include_progress: Literal[True], trophy_group_id: str = 'default', limit: int | None = None, offset: int = 0, page_size: int = 200) TrophyWithProgressIterator
Retrieves all trophies for a specified group within a game title, optionally including user progress.
- Parameters:
np_communication_id – Unique ID of a game title used to request trophy information. This can be obtained from
GameTitleclass.platform – The platform this title belongs to.
trophy_group_id – 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 – Maximum number of trophies to return. None means all available trophies will be returned.
include_progress – If True, includes progress information for each trophy.
offset – The starting point within the collection of trophies.
page_size – The number of trophies to return per page.
- Returns:
Returns the Trophy Generator object with all the information
- Raises:
PSNAWPNotFoundError – If you don’t have any trophies for that game.
PSNAWPForbiddenError – If the user’s profile is private
Warning
Setting
include_progresstoTruewill consume more rate limits as progress information is fetched from a separate endpoint.
- trophy_groups_summary(np_communication_id: str, platform: PlatformType, include_progress: Literal[False] = False) TrophyGroupsSummary[TrophyGroupSummary][source]#
- trophy_groups_summary(np_communication_id: str, platform: PlatformType, include_progress: Literal[True]) TrophyGroupsSummary[TrophyGroupSummaryWithProgress]
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:
np_communication_id – Unique ID of the title used to request trophy information
platform – The platform this title belongs to.
platform – The platform this title belongs to.
include_progress – If True, will fetch results from another endpoint and include progress for trophy group such as name and detail
Warning
Setting
include_progresstoTruewill use twice the amount of rate limit since the API wrapper has to obtain progress from a separate endpoint.- Returns:
TrophyGroupSummary object containing title and title groups trophy information.
- Raises:
PSNAWPNotFoundError – If you don’t have any trophies for that game.
PSNAWPForbiddenError – If the user’s profile is private.
- trophy_summary() 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:
Trophy Summary Object containing all information
- Raises:
PSNAWPForbiddenError – If the user’s profile is private
user_example = psnawp.user(online_id="VaultTec_Trading") print(user_example.trophy_summary())
- trophy_titles(limit: int | None = None, offset: int = 0, page_size: int = 50) TrophyTitleIterator[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.
page_size – The number of items to receive per api request.
offset – Specifies the offset for paginator.
- Returns:
Generator object with TrophyTitle objects.
- Raises:
PSNAWPForbiddenError – If the user’s profile is private.
user_example = psnawp.user(online_id="VaultTec_Trading") for trophy_title in user_example.trophy_titles(limit=None): print(trophy_title)
- trophy_titles_for_title(title_ids: list[str]) TrophyTitleIterator[source]#
Retrieve a summary of the trophies earned by a user for specific titles.
- Parameters:
- Returns:
Generator object with TrophyTitle objects.
- Raises:
PSNAWPForbiddenError – If the user’s profile is private.
Note
title_idcan be obtained from https://andshrew.github.io/PlayStation-Titles/ or fromUniversalSearchuser_example = psnawp.user(online_id="VaultTec_Trading") for trophy_title in user_example.trophy_titles_for_title(title_ids=["CUSA00265_00"]): print(trophy_title)