psnawp_api.models.client module#

Provides Class Client representing the logged in user.

class Client(authenticator: Authenticator)[source]#

Bases: object

The Client class provides the information and methods for the currently authenticated user.

Variables:

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

Note

This class is intended to be used via PSNAWP. See psnawp_api.psnawp.PSNAWP.me()

Initialize a Client instance.

Parameters:

authenticator – The Authenticator instance used for making authenticated requests to the API.

__init__(authenticator: Authenticator) None[source]#

Initialize a Client instance.

Parameters:

authenticator – The Authenticator instance used for making authenticated requests to the API.

property account_id: str#

Gets the account ID of the client logged in the api.

Returns:

account ID of logged in user.

client = psnawp.me()
print(client.account_id)
available_to_play() Generator[User, None, None][source]#

Gets the list of users on your “Notify when available” subscription list.

Returns:

Iterator of user objects.

client = psnawp.me()
available_to_play = client.available_to_play()

for user in available_to_play:
    ...
blocked_list() Generator[User, None, None][source]#

Gets the blocked list and return their account ids.

Returns:

Al blocked users on your block list.

client = psnawp.me()
blocked_list = client.blocked_list()

for blocked_users in blocked_list:
    ...
friend_requests() Generator[User, None, None][source]#

Get the friend request list and returns Generator of received requests.

Returns:

All your friend requests.

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.

client = psnawp.me()
friends_list = client.friends_list()

for friend in friends_list:
    ...
game_entitlements(limit: int | None = None, offset: int = 0, page_size: int = 20, title_ids: list[str] | None = None) GameEntitlementsIterator[source]#

Returns an iterator for retrieving game entitlements (owned titles) associated with the authenticated client.

Note

This class retrieves only PS4 and PS5 game entitlements, as the underlying API endpoints accessed via the PlayStation Android app are limited to these platforms.

Parameters:
  • limit – Limit of titles returned.

  • page_size – The number of items to receive per api request.

  • offset – Specifies the offset for paginator.

  • title_ids – Filter by a specific game title IDs to check if the client owns it.

Returns:

Iterator class GameEntitlementsIterator

get_account_devices() list[dict[str, Any]][source]#

Gets the list of devices the client is logged into.

Returns:

A dict containing info similar to what is shown below:

[
  {
    "deviceId": "[Redacted]",
    "deviceType": "PS4",
    "activationType": "PSN_GAME_V3",
    "activationDate": "2021-02-05T20:11:27.815Z",
    "accountDeviceVector": "[Redacted]"
  }
]

client = psnawp.me()
print(client.get_account_devices())
get_groups(limit: int = 200, offset: int = 0) Generator[Group, None, None][source]#

Gets all the groups you have participated in.

Parameters:
  • limit – The number of groups to receive.

  • offset – Lets you exclude first N items groups. Offset = 10 lets you skip the first 10 groups.

Returns:

Generator of Group Objects.

get_presences(account_ids: list[str]) dict[str, Any][source]#

Gets the presences all the account Ids passed as param.

Returns:

A dict containing info similar to what is shown below:

{
  "basicPresences": [
    {
      "accountId": "5361973517281706660",
      "availability": "unavailable",
      "lastAvailableDate": "2025-04-06T18:36:00.377Z",
      "primaryPlatformInfo": {
        "onlineStatus": "offline",
        "platform": "PS5",
        "lastOnlineDate": "2025-04-06T18:36:00.377Z"
      }
    },
    {
      "accountId": "940512162723934331",
      "availability": "availableToPlay",
      "primaryPlatformInfo": {
        "onlineStatus": "online",
        "platform": "PS5"
      },
      "gameTitleInfoList": [
        {
          "npTitleId": "CUSA14296_00",
          "titleName": "Rust",
          "format": "PS4",
          "launchPlatform": "PS5",
          "gameStatus": "Surviving on the server: Chasm HM [Monthly]"
        }
      ]
    },
    {
      "accountId": "4273405838384737823",
      "availability": "unavailable",
      "lastAvailableDate": "2025-03-02T18:08:15.635Z",
      "primaryPlatformInfo": {
        "onlineStatus": "offline",
        "platform": "PS4",
        "lastOnlineDate": "2025-03-02T18:08:15.635Z"
      }
    }
  ]
}

client = psnawp.me()
print(client.get_presences())
get_profile_legacy() dict[str, Any][source]#

Gets the 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"
    }
  }
}

client = psnawp.me()
print(client.get_profile_legacy())
get_region() Country | None[source]#

Gets the region of the client logged in the api.

Returns:

Returns Country object from Pycountry for logged in user or None if not found.

client = psnawp.me()
print(client.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"
}

client = psnawp.me()
print(client.get_shareable_profile_link())
property online_id: str#

Gets the online ID of the client logged in the api.

Returns:

online ID of logged in user.

client = psnawp.me()
print(client.online_id)
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

Important

Only returns data for PS4 games and above.

Returns:

Iterator class for TitleStats

user_example = psnawp.client()
titles = list(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 GameTitle class.

  • 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:

Warning

Setting include_progress to True will 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_progress to True will 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:
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

client = psnawp.me()
print(client.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:

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

Returns:

Generator object with TrophyTitle objects.

Raises:

PSNAWPForbiddenError – If the user’s profile is private.

Note

title_id can be obtained from https://andshrew.github.io/PlayStation-Titles/ or from UniversalSearch

user_example = psnawp.user(online_id="VaultTec_Trading")
for trophy_title in user_example.trophy_titles_for_title(title_ids=["CUSA00265_00"]):
    print(trophy_title)