danielwerg / r6api.js

🍫 Node.js wrapper around Rainbow Six Siege APIs
https://npm.im/r6api.js
MIT License
111 stars 19 forks source link

Mark userId nullable (Breaking Change) #85

Open BadCoder1337 opened 2 years ago

BadCoder1337 commented 2 years ago

In rare cases userId is null. I'm usure why but it seems to represent a linked account which doesn't started a game. Raw API response to nameOnPlatform search:

{
    "profileId": "d3dde2ca-7c92-468e-89b4-9dab253225ce",
    "userId": null,
    "platformType": "psn",
    "idOnPlatform": "2072355385337540186",
    "nameOnPlatform": "AreYouAhueliTut"
}

Library response to idOnPlatform search:

  {
    "id": "07c8acb0-542a-4ad0-b0b0-0a714e346584",
    "userId": null,
    "idOnPlatform": "76561198106338458",
    "platform": "steam",
    "nameOnPlatform": "76561198106338458",
    "avatar": {
      "146": "https://ubisoft-avatars.akamaized.net/null/default_146_146.png",
      "256": "https://ubisoft-avatars.akamaized.net/null/default_256_256.png",
      "500": "https://ubisoft-avatars.akamaized.net/null/default_tall.png"
    }
  }
danielwerg commented 2 years ago

https://public-ubiservices.ubi.com/v3/profiles?platformType=psn&namesOnPlatform=AreYouAhueliTut Returns:

{
  "profiles": [
    {
      "profileId": "d3dde2ca-7c92-468e-89b4-9dab253225ce",
      "userId": "c4fdcaf8-3282-45ec-826b-8f91b4dd1794",
      "platformType": "psn",
      "idOnPlatform": "2072355385337540186",
      "nameOnPlatform": "AreYouAhueliTut"
    }
  ]
}

For second case it does indeed returns null for userId

BadCoder1337 commented 2 years ago

I took the PSN example from my Postman collection, it is outdated. But null is still possible, and it should be represented in types.

danielwerg commented 2 years ago

Is there a reason we use userId instead of profileId while building avatar url? Can't remember.

BadCoder1337 commented 2 years ago

Ubisoft doesn't proxy platform avatar behind profileId URL, there's a blank avatar. All trackers (e.g. R6DB) display userId avatar for console profiles.

danielwerg commented 2 years ago

I went down a rabbit hole, even more lost now. How does r6tracker displays pfp for this user: https://r6.tracker.network/profile/xbox/Mono%20wins

BadCoder1337 commented 2 years ago

Looks like they're using some Xbox API to retrieve platform avatar by idOnPlatform. But this is not r6api.js business, IMHO. Also, I sure there's no similar API for PSN.