Simple Xbox Live API wrapper.
$ npm install @xboxreplay/xboxlive-api
$ git clone [email protected]:XboxReplay/xboxlive-api.git
$ npm run build
$ npm run test
import XboxLiveAPI from '@xboxreplay/xboxlive-api';
XboxLiveAPI.getPlayerSettings('Zeny IC', {
userHash: '1890318589445465111',
XSTSToken: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhIjoiYiJ9.iMrN7XT_jCcRXWKwUo_JPWeRO75dBOGTzerAO'
}, ['GameDisplayPicRaw', 'Gamerscore', 'Location'])
.then(console.info)
.catch(console.error);
Sample response:
[
{
"id": "GameDisplayPicRaw",
"value": "http://images-eds.xboxlive.com/image?url=wHwbXKif8cus8csoZ03RWwcxuUQ9WVT6xh5XaeeZD02wEfGZeuD.XMoGFVYkwHDq4Ch7pcu9E3UwDqy.fzrTaviUvY1c8gvrWRzLTqFKUVap_Nvh0.Em2IsAWtHcMFeVpY2boMYiy03w887.tSGAT62Na2z3k33eMWnP12mY2x0-&format=png"
}
{
"id": "Gamerscore",
"value": "5610"
},
{
"id": "Location",
"value": "Paris, France"
}
]
The fastest way to generate a valid authorization is to use our XboxLive-Auth module which returns a userHash and a XSTSToken for a specified account.
getPlayerXUID - Returns targeted player's XUID:
getPlayerXUID(
gamertag: string;
authorization: {
userHash: string;
XSTSToken: string;
};
): Promise<string>
getPlayerSettings - Returns targeted player's settings:
getPlayerSettings(
gamertag: string;
authorization: {
userHash: string;
XSTSToken: string;
};
settings?: [
'GameDisplayPicRaw' |
'Gamerscore' |
'Gamertag' |
'AccountTier' |
'XboxOneRep' |
'PreferredColor' |
'RealName' |
'Bio' |
'Location'
];
): Promise<{
id: string;
value: string;
}[]>
getPlayerScreenshots - Returns targeted player's screenshots:
getPlayerScreenshots(
gamertag: string,
authorization: {
userHash: string;
XSTSToken: string;
},
maxItems: number = 25
): Promise<{
screenshots: {
screenshotId: string;
resolutionHeight: number;
resolutionWidth: number;
state: string;
datePublished: string;
dateTaken: string;
lastModified: string;
userCaption: string;
type: 'UserGenerated' | 'AutoGenerated';
scid: string;
titleId: number;
rating: number;
ratingCount: number;
views: number;
titleData: string;
systemProperties: string;
savedByUser: boolean;
achievementId: string;
greatestMomentId: string | null;
thumbnails: {
uri: string;
fileSize: 0;
thumbnailType: 'Small' | 'Large';
}[];
screenshotUris: {
uri: string;
fileSize: number;
uriType: 'Download';
expiration: string;
}[];
xuid: string;
screenshotName: string;
titleName: string;
screenshotLocale: string;
screenshotContentAttributes: string;
deviceType: string;
}[];
pagingInfo: {
continuationToken: string | null
};
}>
getPlayerGameclips - Returns targeted player's gameclips:
getPlayerScreenshots(
gamertag: string,
authorization: {
userHash: string,
XSTSToken: string
},
maxItems: number = 25
): Promise<{
gameClips: {
gameClipId: string;
state: string;
datePublished: string;
dateRecorded: string;
lastModified: string;
userCaption: string;
type: 'UserGenerated' | 'AutoGenerated';
durationInSeconds: number;
scid: string;
titleId: number;
rating: number;
ratingCount: number;
views: number;
titleData: string;
systemProperties: string;
savedByUser: boolean;
achievementId: string;
greatestMomentId: string | null;
thumbnails: {
uri: string;
fileSize: 0;
thumbnailType: 'Small' | 'Large';
}[];
gameClipUris: {
uri: string;
fileSize: number;
uriType: 'Download';
expiration: string;
}[];
xuid: string;
clipName: string;
titleName: string;
gameClipLocale: string;
clipContentAttributes: string;
deviceType: string;
commentCount: number;
likeCount: number;
shareCount: number;
partialViews: number;
}[];
pagingInfo: {
continuationToken: string | null
};
}>
call - Generic method to call the API with a custom URI:
call(
uri: string;
authorization: {
userHash: string;
XSTSToken: string;
};
properties?: {
method?: string; // HTTP method
payload?: any; // Body payload for PATCH | POST | PUT requests
qs?: any; // Query String
}
): Promise<any>
Please refer to https://docs.microsoft.com/en-us/windows/uwp/xbox-live/xbox-live-rest/uri/atoc-xboxlivews-reference-uris.