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.