npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@vince144/r6-api

v2.2.2

Published

An api for fetching player statistics from Ubisoft's Rainbow Six website.

Downloads

9

Readme

A simple api that fetches Rainbow Six player statistics

https://github.com/vince1444/r6-api/wiki

Important

Ubisoft's website requires you to have an account with them to fetch player statistics. Likewise, this api also requires a valid Ubisoft email/password.

Example Usage

const r6api = require('@vince144/r6-api');

let email = 'aValidEmail';
let password = 'aValidPassword';
let platform = 'uplay';
let username = 'aValidUsernameToLookup';
//Neon Dawn is '1' in Ubi's request structure
let season = '1';

let account = r6api.createAccount(email, password, platform);
async function fetchStats() { 
   let session = await r6api.createSession(account).catch(e => { console.error(e) }); 
   let player = await r6api.createPlayer(username, platform, session).catch(e => { console.error(e) }); 
   let neonDawnStats = await r6api.getStatsBySeason(player, session, season).catch(e => { console.error(e) }); 
   console.log(neonDawnStats); 
}
fetchStats();

/*OUTPUT: 
[
  {
    max_mmr: 2681,
    skill_mean: 26.0734410996,
    deaths: 137,
    profile_id: 'e96ae749-8939-43ed-895f-bf1817e849d9',
    next_rank_mmr: 2800,
    rank: 16,
    max_rank: 16,
    board_id: 'pvp_ranked',
    skill_stdev: 6.1882002469,
    kills: 160,
    last_match_skill_stdev_change: -0.039727164,
    update_time: '2020-12-18T17:19:23.498000+00:00',
    last_match_mmr_change: -74,
    abandons: 0,
    season: 20,
    top_rank_position: 0,
    last_match_skill_mean_change: -0.7341182744,
    mmr: 2607,
    previous_rank_mmr: 2600,
    last_match_result: 2,
    wins: 17,
    region: 'ncsa',
    losses: 16
  }
]
*/

createAccount(email string, password string, platform string)

Creates an account Object. Returns a promise, and if fulfilled, resolves an account Object.

let account = r6api.createAccount('aValidEmail', 'aValidPassword', 'uplay');
console.log(account);

/*OUTPUT:
{
  email: '[email protected]',
  password: 'asdada',
  platform: 'uplay'
}
*/

createSession(account account Object)

Creates an session Object. Returns a promise, and if resolved, returns an session Object.

async function example() {
    let session = r6api.createSession(account).catch(e => { console.error(e) });
    console.log(session);
}
example();

/*OUTPUT:
{
  appId: '3587dcbb-7f81-457c-9781-0e3f29f6f56a',
  spaceId: '5172a557-50b5-4665-b7db-e3f2e8c5041d',
  sessionId: '8c5385a6-b63e-4511-b331-4b32cdd36b49',
  //token will be longer than this
  token: 'skdjkajdaKJDKASJDKAJDK',
  startDate: '20201018',
  endDate: '20201217'
}
*/

getSessionResponse(account account Object)

Fetches the full server response when making the same URL request used in the createSession() function.

let username = 'madeMan43930230';
let platform = 'uplay';
async function example() {
    let sessionResponse = await r6api.getSessionResponse(username, platform, session).catch(e => { console.error(e) });
    console.log(sessionResponse);
}
example();

/*OUTPUT:
{
  platformType: 'uplay',
  //actual ticket is longer
  ticket: 'kasdkajDKSKADJ',
  twoFactorAuthenticationTicket: null,
  profileId: '9990bd9c-603c-4a74-b14f-35eca6b71a5d',
  userId: '9990bd9c-603c-4a74-b14f-35eca6b71a5d',
  nameOnPlatform: 'vince1444',
  environment: 'Prod',
  expiration: '2020-12-18T20:50:24.4971208Z',
  spaceId: '2c017c99-65c2-4b69-950d-f3d9c22ede59',
  clientIp: ':)',
  clientIpCountry: ':)',
  serverTime: '2020-12-18T17:50:24.5010346Z',
  //actual sessionId is longer
  sessionId: 'a-b-c-d',
  //actual session key is longer
  sessionKey: 'asdkjakdjalksjd==',
  rememberMeTicket: null
}
*/

createPlayer(username string, platform string, session session Object)

Creates a player Object. Returns a promise, and if fulfilled, resolves a player Object and pushes to the global players[] array.

let username = 'madeMan43930230';
let platform = 'uplay';
async function example() {
    let player = await r6api.createPlayer(username, platform, session).catch(e => { console.error(e) });
    console.log(player);
}
example();

/*OUTPUT:
{
  username: 'madeMan43930230',
  platform: 'uplay',
  id: '80c432fb-6a76-4ca8-a5a2-69c6be177185',
  rank: null,
  kills: null,
  deaths: null
}
*/

getProfileResponse(player player Object, session session Object)

Fetches the full server response when making the same URL request used in the createPlayer() function.

async function example() {
    let profileResponse = await r6api.getProfileResponse(player, session).catch(e => { console.error(e) });
    console.log(profileResponse);
}
example();

/*OUTPUT:
{
  profiles: [
    {
      profileId: '80c432fb-6a76-4ca8-a5a2-69c6be177185',
      userId: '80c432fb-6a76-4ca8-a5a2-69c6be177185',
      platformType: 'uplay',
      idOnPlatform: '80c432fb-6a76-4ca8-a5a2-69c6be177185',
      nameOnPlatform: 'madeMan43930230'
    }
  ]
}
*/

getStats(player player Object, session session Object)

Fetches the current season's general stats of a player. Returns a promise, and if fulfilled, resolves the stats.

async function example() {
    let stats = await r6api.getStats(player, session).catch(e => { console.error(e) });
    console.log(stats);
}
example();

/*OUTPUT:
{
  players: {
    '80c432fb-6a76-4ca8-a5a2-69c6be177185': {
      max_mmr: 0,
      skill_mean: 26.5744265626,
      deaths: 0,
      profile_id: '80c432fb-6a76-4ca8-a5a2-69c6be177185',
      next_rank_mmr: 0,
      rank: 0,
      max_rank: 0,
      board_id: 'pvp_ranked',
      skill_stdev: 7.9519144961,
      kills: 0,
      last_match_skill_stdev_change: 0,
      update_time: '1970-01-01T00:00:00+00:00',
      last_match_mmr_change: 0,
      abandons: 0,
      season: 20,
      top_rank_position: 0,
      last_match_skill_mean_change: 0,
      mmr: 2657,
      previous_rank_mmr: 0,
      last_match_result: 0,
      wins: 0,
      region: 'ncsa',
      losses: 0
    }
  }
}
*/

getStatsBySeason(player player Object, session session Object, season Integer)

Fetches the current stats by season of a player. There are 20 seasons. Neon Dawn is 1, Shadow Legacy is 2, Steel Wave is 3, and so on until Health at 20. Returns a promise, and if fulfilled, resolves the stats by specified season.

let season = '2';
async function example() {
    let shadowLegacyStats = await r6api.getStatsBySeason(player, session, season).catch(e => { console.error(e) });
    console.log(shadowLegacyStats);
}
example();

/*OUTPUT:
[
  {
    max_mmr: 2807,
    skill_mean: 27.6738928455,
    deaths: 807,
    profile_id: '80c432fb-6a76-4ca8-a5a2-69c6be177185',
    next_rank_mmr: 2800,
    rank: 16,
    max_rank: 17,
    board_id: 'pvp_ranked',
    skill_stdev: 3.7867713646,
    kills: 1098,
    last_match_skill_stdev_change: -0.008890644,
    update_time: '2020-12-18T17:38:38.636000+00:00',
    last_match_mmr_change: -27,
    abandons: 1,
    season: 19,
    top_rank_position: 0,
    last_match_skill_mean_change: -0.2703950966,
    mmr: 2767,
    previous_rank_mmr: 2600,
    last_match_result: 2,
    wins: 100,
    region: 'ncsa',
    losses: 88
  }
]
*/

getStatsByOperator(player player Object, session session Object, team optional String)

Like the other two stat functions, it returns the stats but by each operator. Optional parameter team; default = 'attacker,defender. It returns every operator on specified team, so the request may take a second or two. Returns a promise, and if fulfilled, resolves the stats of each operator.

let team = 'attacker';
async function example() {
    let stats = await r6api.getStatsByOperator(player, session, team).catch(e => { console.error(e) });
    console.log(stats);
}
example();

/*OUTPUT:
{
  attacker: [
    {
      type: 'Generalized',
      statsType: 'operators',
      statsDetail: 'Hibana',
      matchesPlayed: 7,
      roundsPlayed: 13,
      minutesPlayed: 49,
      matchesWon: 4,
      matchesLost: 3,
      roundsWon: 8,
      roundsLost: 5,
      kills: 23,
      assists: 0,
      death: 7,
      headshots: 14,
      meleeKills: 0,
      teamKills: 0,
      openingKills: 2,
      openingDeaths: 0,
      trades: 1,
      openingKillTrades: 1,
      openingDeathTrades: 0,
      revives: 8,
      distanceTravelled: 2401,
      winLossRatio: 1.3333,
      killDeathRatio: [Object],
      headshotAccuracy: [Object],
      killsPerRound: [Object],
      roundsWithAKill: [Object],
      roundsWithMultiKill: [Object],
      roundsWithOpeningKill: [Object],
      roundsWithOpeningDeath: [Object],
      roundsWithKOST: [Object],
      roundsSurvived: [Object],
      roundsWithAnAce: [Object],
      roundsWithClutch: [Object],
      timeAlivePerMatch: 221.1428,
      timeDeadPerMatch: 44.5714,
      distancePerRound: 184.6923
    }
    ...
    ...
    ...
    ...
    
  ]
}
*/