Skip to main content

Users API

getProfileFromUserName

A call to this function will retrieve the profile of the username being requested. If the user cannot be found (either due to non-existence or privacy settings), an error will be thrown.

caution

This is a legacy API endpoint function. If you are just trying to get a user's accountId, makeUniversalSearch() is recommended instead. This endpoint is here because it can return interesting presence information when the user is playing on a legacy console such as a PS3.

Examples

Look up a user

import { getProfileFromUserName } from "psn-api";

const response = await getProfileFromUserName(authorization, "xelnia");

Returns

The following properties are contained within a profile object that is returned.

NameTypeDescription
onlineIdstringThe account's online username.
accountIdstringThe account's internal ID value, which can be used for numerous calls to the PSN API.
npIdstring
avatarUrlsArray<{ size: string; avatarUrl: string; }>
plus0 or 1Whether or not the account is a PlayStation Plus subscriber.
aboutMestring
languagesUsedstring[]
trophySummary{ level: number; progress: number; earnedTrophies: { bronze: number; silver: number; gold: number; platinum: number; }}The account's trophy level, progress towards the next level, and total number of torphies earned by type.
isOfficiallyVerifiedboolean
personalDetail`{ firstName: string; lastName: string; profilePictureUrls: Array<{ size: string; profilePictureUrl: string; }>}
personalDetailSharingstring
personalDetailSharingRequestMessageFlagboolean
primaryOnlineStatusstring
presencesArray<{ onlineStatus: string; hasBroadcastData: string; lastOnlineDate: string; }>
friendRelationstring
requestMessageFlagboolean
blockingbooleanWhether or not the account is blocked by the retrieving authentication context. For example, if you are using psn-api with your account's access token, and your account has blocked the account you're looking up, this will be true.
followingboolean
consoleAvailability{ availabilityStatus: string; }

Parameters

NameTypeDescription
authorizationAuthorizationPayloadAn object that must contain an accessToken. See this page for how to get one.
userNamestringThe username for the user you wish to retrieve a profile for.

Source

user/getProfileFromUserName.ts


getProfileFromAccountId

A call to this function will retrieve some of the profile information of the account ID being requested. If the account's profile cannot be found (either due to non-existence or privacy settings), an error will be thrown.

Examples

Look up a user

import { getProfileFromAccountId } from "psn-api";

const response = await getProfileFromAccountId(
authorization,
"962157895908076652"
);

Returns

The following properties are contained within a profile object that is returned.

NameTypeDescription
onlineIdstringThe account's online username.
aboutMestring
avatarsArray<{ size: string; url: string; }>
languagesstring[]
isPlusbooleanWhether or not the account is a PlayStation Plus subscriber.
isOfficiallyVerifiedboolean
isMebooleanWhether or not the profile is the one linked to the current Npsso.

Parameters

NameTypeDescription
authorizationAuthorizationPayloadAn object that must contain an accessToken. See this page for how to get one.
accountIdstringThe accountId for the user you wish to retrieve a profile for.

Source

user/getProfileFromAccountId.ts


getUserFriendsAccountIds

A call to this function will retrieve the list of friended accountId values associated with the given accountId parameter. If the friends list cannot be retrieved (either due to the given accountId not existing or due to the user's privacy settings), an error will be thrown.

To find a user's accountId, the makeUniversalSearch() function can be used.

Examples

Look up the accounts on your friends list

import { getUserFriendsAccountIds } from "psn-api";

const response = await getUserFriendsAccountIds(authorization, "me");

Look up the accounts on another user's friends list

import { getUserFriendsAccountIds, makeUniversalSearch } from "psn-api";

const searchResponse = await makeUniversalSearch(
authorization,
"NeutraLiTe",
"SocialAllAccounts"
);

const foundAccountId =
searchResponse.domainResponses[0].results[0].socialMetadata.accountId;

// If this user's friends list is private, this call will throw an error.
const userFriendsAccountIds = await getUserFriendsAccountIds(
authorization,
foundAccountId
);

Returns

NameTypeDescription
friendsstring[]The accountId values of the users on the target user's friends list.
totalItemCountnumberThe total number of friends on the target user's friends list.
nextOffsetnumber
previousOffsetnumber

Parameters

NameTypeDescription
authorizationAuthorizationPayloadAn object that must contain an accessToken. See this page for how to get one.
accountIdstringThe account whose trophy list is being retrieved. Use "me" for the authenticating account. To find a user's accountId, the makeUniversalSearch() function can be used.

Options

These are the possible values that can be in the options object (the third parameter of the function).

NameTypeDescription
limitnumberLimit the number of trophies returned.
offsetnumberReturn trophy data from this result onwards.

Source

user/getUserFriendsAccountIds.ts


getRecentlyPlayedGames

A call to this function will retrieve a list of recently played games for the user associated with the accessToken in the provided AuthorizationPayload.

Examples

import { getRecentlyPlayedGames } from "psn-api";

const recentlyPlayedGames = await getRecentlyPlayedGames(authorization, {
limit: 10,
categories: ["ps4_game", "ps5_native_game"]
});

Returns

NameTypeDescription
data.gameLibraryTitlesRetrieve.gamesRecentlyPlayedGame[]List of recently played games.

Parameters

NameTypeDescription
authorizationAuthorizationPayloadAn object that must contain an accessToken. See this page for how to get one.

Options

These are the possible values that can be in the options object (the second parameter of the function).

NameTypeDescription
limitnumberLimit the number of games returned. Defaults to 50.
categoriesstring[]Limit the categories of games returned. Valid entries are ps4_game and ps5_native_game.

Source

graphql/getRecentlyPlayedGames.ts