r6statapi

1.2.5 • Public • Published

R6StatAPI

An API wrapper for Rainbow Six Seige written in JavaScript.

Table of Contents

  1. Installation
  2. Getting Started
  3. Functions
  4. Support

Installation

npm i r6statapi

Getting Started

To get started you will need a Ubisoft login, it is best to create a new account and not the account you normally use. Create a new account here

The example below has the email and password variables hardcoded but it would be better to use dotenv to manage environment variables.

import r6statapi from 'r6statapi';

const api = new r6statapi();

// replace with your own information
const email = "test@gmail.com"
const password = "Password123"
const usermame = "User1"
const platform = "uplay"

// login and get token
const token = await api.getAuth(email, password)
console.log(token)

// fetch user by username
const user = await api.getUserByUsername(userName, platform);
console.log(user);

// example response
{
  profileId: 'afc2afec-b9ed-4988-bffa-58e78eedfa93',
  userId: 'afc2afec-b9ed-4988-bffa-58e78eedfa93',
  platformType: 'uplay',
  idOnPlatform: 'AFC2AFEC-B9ED-4988-BFFA-58E78EEDFA93',
  nameOnPlatform: 'CaleyW1'
}

Functions

Table of Contents

  1. Auth
  2. GetUserByUsername
  3. GetUserByUserId
  4. GetUserProgression
  5. GetServerStatus
  6. GetUserRank
  7. GetUserStats
  8. GetOperators

Auth

Signs into the Ubisoft a returns a token.

await api.getAuth(email, password)

Example response

ewogICJ2ZXIiOiAiMSIsCiAgImFpZCI6ICJlM2Q1ZWE5ZS01MGJkLTQzYjctODhiZi0zOTc5NGY0ZTNkNDAiLAogICJlbnYiOiAiUHJvZCIsCiAgInNpZCI6ICI2YzVlY2E4MS1jYWI3LTQ0NjItOWUzOC04YjZkODA5OWQ1ZjEiLAogICJ0eXAiOiAiSldFIiwKICAiZW5jIjogIkExMjhDQkMiLAogICJpdiI6ICJPellRVVNkSkswNzJURTFJTXVpdFhnIiwKICAiaW50IjogIkhTMjU2IiwKICAia2lkIjogImFkNWNjMzFhLWI2ZmQtNGYyZS04N2JmLTNjZjRkOTc1OTY2NSIKfQ.-F6ZqzG9mOze0HRYJh3Ub23dQUR9BLR-VM7hMgbisN3tQZ1XLgZFyVH2sFmmX4VMPEKVG9e_PGLn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6D-uEkAhBFsibp3tOIzWAjQChCR89hJy9IS2O7PMWs31rxINAKdx43jb6llgTRsUGDXYLL1eKYecUd7orY8frlAYXU1xLmDBzBpn6wzbMRNNoFfiI1KG9rUKR8EDPUv26GcfsBzkuSHeFXSi_Xhg.oMj2gpJl_2eOj-pFuYvFyWr_t1JR48zgb2st82KTKWk

Get user by username

Gets a user by username

await api.getUserByUsername(userName, platform);

Example response

{
  profileId: 'afc2afec-b9ed-4988-bffa-58e78eedfa93',
  userId: 'afc2afec-b9ed-4988-bffa-58e78eedfa93',
  platformType: 'uplay',
  idOnPlatform: 'AFC2AFEC-B9ED-4988-BFFA-58E78EEDFA93',
  nameOnPlatform: 'CaleyW1'
}

Get user by userId

Gets a user by userId

await api.getUserById(user.userId, platform);

Example response

[
  {
    profileId: 'afc2afec-b9ed-4988-bffa-58e78eedfa93',
    userId: 'afc2afec-b9ed-4988-bffa-58e78eedfa93',
    platformType: 'uplay',
    idOnPlatform: 'afc2afec-b9ed-4988-bffa-58e78eedfa93',
    nameOnPlatform: 'CaleyW1'
  },
  {
    profileId: 'f02cbe10-2411-43d9-b449-5366888201a2',
    userId: 'afc2afec-b9ed-4988-bffa-58e78eedfa93',
    platformType: 'steam',
    idOnPlatform: '76561198172917981',
    nameOnPlatform: '76561198172917983'
  },
  {
    profileId: '91193155-2b57-48f1-b69b-556f5e4ccfea',
    userId: 'afc2afec-b9ed-4988-bffa-58e78eedfa93',
    platformType: 'twitch',
    idOnPlatform: '469658264',
    nameOnPlatform: 'calbob'
  }
]

Get user progression

gets the progression for a user

await api.getUserProgression(user.userId, platform);

Example response

{
  level: 326,
  xp: 129949
}

Get server status

Returns the status of a platform

platforms: pc, xbox, ps4

await api.getServerStatus(platfrom)

Example response

{
  platform: 'PC',
  status: 'Online',
  maintenance: null,
  impactedFeatures: []
}

Get user rank

Returns statistics for different gamemodes

await api.getUserRank(player.userId, platfrom);

Example response

{
  casual: {
    profile_board_id: 'casual',
    id: '7acf490b-4bfd-40df-97b6-ebbbe6ebc702',
    max_rank: 0,
    max_rank_points: 0,
    platform_family: 'pc',
    rank: 0,
    rank_points: 0,
    season_id: 33,
    top_rank_position: 0,
    deaths: 0,
    kills: 0,
    abandons: 0,
    losses: 0,
    wins: 0
  },
  event: {
    profile_board_id: 'event',
    id: '7acf490b-4bfd-40df-97b6-ebbbe6ebc702',
    max_rank: 0,
    max_rank_points: 0,
    platform_family: 'pc',
    rank: 0,
    rank_points: 0,
    season_id: 33,
    top_rank_position: 0,
    deaths: 0,
    kills: 0,
    abandons: 0,
    losses: 0,
    wins: 0
  },
  warmup: {
    profile_board_id: 'warmup',
    id: '7acf490b-4bfd-40df-97b6-ebbbe6ebc702',
    max_rank: 0,
    max_rank_points: 0,
    platform_family: 'pc',
    rank: 0,
    rank_points: 0,
    season_id: 33,
    top_rank_position: 0,
    deaths: 12,
    kills: 14,
    abandons: 1,
    losses: 1,
    wins: 0
  },
  standard: {
    profile_board_id: 'standard',
    id: '7acf490b-4bfd-40df-97b6-ebbbe6ebc702',
    max_rank: 0,
    max_rank_points: 0,
    platform_family: 'pc',
    rank: 0,
    rank_points: 0,
    season_id: 33,
    top_rank_position: 0,
    deaths: 4,
    kills: 7,
    abandons: 0,
    losses: 1,
    wins: 0
  },
  ranked: {
    profile_board_id: 'ranked',
    id: '7acf490b-4bfd-40df-97b6-ebbbe6ebc702',
    max_rank: 32,
    max_rank_points: 4155,
    platform_family: 'pc',
    rank: 32,
    rank_points: 4100,
    season_id: 33,
    top_rank_position: 0,
    deaths: 433,
    kills: 581,
    abandons: 1,
    losses: 56,
    wins: 49
  }
}

Get User Stats

Get seasonal user statistics

Field Type Required options
userId id yes
platform string yes uplay, xbox, ps4
view string yes seasonal
aggregation string yes summary
gameMode string yes All, Casual, Ranked
teamRole string yes All
season string yes format Y(No.)S(No.) Example Y6S3
const userStats = await api.getUserStats(
  userId,
  platform,
  view,
  aggregation,
  gameMode,
  teamRole,
  season
);

Example response

[
  {
    gameMode: 'all',
    type: 'Seasonal',
    statsType: 'summary',
    statsDetail: 'summary',
    seasonYear: 'Y9',
    seasonNumber: 'S1',
    matchesPlayed: 100,
    roundsPlayed: 619,
    minutesPlayed: 2451,
    matchesWon: 47,
    matchesLost: 53,
    roundsWon: 303,
    roundsLost: 316,
    kills: 574,
    assists: 116,
    death: 414,
    headshots: 217,
    meleeKills: 2,
    teamKills: 2,
    openingKills: 64,
    openingDeaths: 44,
    trades: 21,
    openingKillTrades: 4,
    openingDeathTrades: 4,
    revives: 13,
    distanceTravelled: 113204,
    winLossRatio: 0.8868,
    killDeathRatio: { value: 1.3865, p: 0 },
    headshotAccuracy: { value: 0.378, p: 0 },
    killsPerRound: { value: 0.9273, p: 0 },
    roundsWithAKill: { value: 0.5703, p: 0 },
    roundsWithAMultiKill: { value: 0.2456, p: 0 },
    roundsWithOpeningKill: { value: 0.1034, p: 0 },
    roundsWithOpeningDeath: { value: 0.0711, p: 0 },
    roundsWithKOST: { value: 0.6478, p: 0 },
    roundsSurvived: { value: 0.3312, p: 0 },
    roundsWithAnAce: { value: 0.0048, p: 0 },
    roundsWithClutch: { value: 0.0113, p: 0 },
    timeAlivePerMatch: 631.35,
    timeDeadPerMatch: 175.88,
    distancePerRound: 182.8821
  }
]

Get Operator

Gets seasonal operator statistics

Field Type Required options
userId Id Yes
platform string Yes uplay, xbox, ps4
view string Yes seasonal
aggregation string Yes operator
gameMode string Yes All, Casual, Ranked
team role string Yes Attacker, Defender
season string Yes format Y(No.)S(No.) Example Y6S3
const operator = await api.getOperators(
  userId,
  platform,
  view,
  aggregation,
  gameMode,
  teamRole,
  season
);

Example Response

[
  {
    "attacker": [
      {
        "type": "Seasonal",
        "statsType": "operators",
        "statsDetail": "Iq",
        "seasonYear": "Y6",
        "seasonNumber": "S3",
        "matchesPlayed": 3,
        "roundsPlayed": 4,
        "minutesPlayed": 12,
        "matchesWon": 1,
        "matchesLost": 2,
        "roundsWon": 2,
        "roundsLost": 2,
        "kills": 2,
        "assists": 0,
        "death": 3,
        "headshots": 1,
        "meleeKills": 0,
        "teamKills": 0,
        "openingKills": 0,
        "openingDeaths": 1,
        "trades": 0,
        "openingKillTrades": 0,
        "openingDeathTrades": 0,
        "revives": 0,
        "distanceTravelled": 604,
        "winLossRatio": 0.5,
        "killDeathRatio": {
          "value": 0.6667,
          "p": 0
        },
        "headshotAccuracy": {
          "value": 0.5,
          "p": 0
        },
        "killsPerRound": {
          "value": 0.5,
          "p": 0
        },
        "roundsWithAKill": {
          "value": 0.25,
          "p": 0
        },
        "roundsWithMultiKill": {
          "value": 0.25,
          "p": 0
        },
        "roundsWithOpeningKill": {
          "value": 0,
          "p": 0
        },
        "roundsWithOpeningDeath": {
          "value": 0.25,
          "p": 0
        },
        "roundsWithKOST": {
          "value": 0.25,
          "p": 0
        },
        "roundsSurvived": {
          "value": 0.25,
          "p": 0
        },
        "roundsWithAnAce": {
          "value": 0,
          "p": 0
        },
        "roundsWithClutch": {
          "value": 0,
          "p": 0
        },
        "timeAlivePerMatch": 80,
        "timeDeadPerMatch": 60,
        "distancePerRound": 151
      }
    ]
  },
  {
    "defender": [
      {
        "type": "Seasonal",
        "statsType": "operators",
        "statsDetail": "Ela",
        "seasonYear": "Y6",
        "seasonNumber": "S3",
        "matchesPlayed": 3,
        "roundsPlayed": 3,
        "minutesPlayed": 10,
        "matchesWon": 1,
        "matchesLost": 2,
        "roundsWon": 1,
        "roundsLost": 2,
        "kills": 0,
        "assists": 2,
        "death": 3,
        "headshots": 0,
        "meleeKills": 0,
        "teamKills": 0,
        "openingKills": 0,
        "openingDeaths": 1,
        "trades": 0,
        "openingKillTrades": 0,
        "openingDeathTrades": 0,
        "revives": 0,
        "distanceTravelled": 553,
        "winLossRatio": 0.5,
        "killDeathRatio": {
          "value": 0,
          "p": 0
        },
        "headshotAccuracy": {
          "value": 0,
          "p": 0
        },
        "killsPerRound": {
          "value": 0,
          "p": 0
        },
        "roundsWithAKill": {
          "value": 0,
          "p": 0
        },
        "roundsWithMultiKill": {
          "value": 0,
          "p": 0
        },
        "roundsWithOpeningKill": {
          "value": 0,
          "p": 0
        },
        "roundsWithOpeningDeath": {
          "value": 0.3333,
          "p": 0
        },
        "roundsWithKOST": {
          "value": 0,
          "p": 0
        },
        "roundsSurvived": {
          "value": 0,
          "p": 0
        },
        "roundsWithAnAce": {
          "value": 0,
          "p": 0
        },
        "roundsWithClutch": {
          "value": 0,
          "p": 0
        },
        "timeAlivePerMatch": 80,
        "timeDeadPerMatch": 40,
        "distancePerRound": 184.3333
      }
    ]
  }
]

Support

For any questions, bugs or feedback, please use our Discord or create an issue on Github

Package Sidebar

Install

npm i r6statapi

Weekly Downloads

76

Version

1.2.5

License

MIT

Unpacked Size

3.36 MB

Total Files

82

Last publish

Collaborators

  • calumw1