OpenXbox / xbox-webapi-python

A python library to authenticate with Xbox Live via your Microsoft Account and provides Xbox related Web-API.
https://pypi.python.org/pypi/xbox-webapi
MIT License
176 stars 45 forks source link

Game stats #3

Closed kufhjer closed 6 years ago

kufhjer commented 6 years ago

Hey, I am looking for the GameStats provider based on XUID and TitleId. It would give me back the GameStats for a specific game. Hope this will be added, or if you have the endpoints available that would be awsome aswell.

tuxuser commented 6 years ago

Can you give me an example how returned data looks?

kufhjer commented 6 years ago

Offcourse.

{"groups":[{"name":"Hero","titleid":950328474,"statlistscollection":[{"arrangebyfield":"xuid","arrangebyfieldid":2535431190592405,"stats":[{"groupproperties":{"Ordinal":1,"SortOrder":"Descending","DisplayName":"Total matches played","DisplayFormat":"Integer"},"xuid":2535431190592405,"scid":"3b040100-2400-45a2-a30c-d45238a4dc9a","name":"Stat-total-played","type":"Integer","value":600,"properties":{"DisplayName":"Total matches played"}},{"groupproperties":{"Ordinal":2,"SortOrder":"Descending","DisplayName":"Total wins","DisplayFormat":"Integer"},"xuid":2535431190592405,"scid":"3b040100-2400-45a2-a30c-d45238a4dc9a","name":"Stat-total-wins","type":"Integer","value":24,"properties":{"DisplayName":"Total wins"}},{"groupproperties":{"Ordinal":3,"SortOrder":"Descending","DisplayName":"Total kills","DisplayFormat":"Integer"},"xuid":2535431190592405,"scid":"3b040100-2400-45a2-a30c-d45238a4dc9a","name":"Stat-total-kills","type":"Integer","value":897,"properties":{"DisplayName":"Total kills"}},{"groupproperties":{"Ordinal":4,"SortOrder":"Descending","DisplayName":"Total headshots","DisplayFormat":"Integer"},"xuid":2535431190592405,"scid":"3b040100-2400-45a2-a30c-d45238a4dc9a","name":"Stat-total-headshots","type":"Integer","value":143,"properties":{"DisplayName":"Total headshots"}},{"groupproperties":{"Ordinal":5,"SortOrder":"Descending","DisplayName":"Solo matches played","DisplayFormat":"Integer"},"xuid":2535431190592405,"scid":"3b040100-2400-45a2-a30c-d45238a4dc9a","name":"Stat-solo-played","type":"Integer","value":159,"properties":{"DisplayName":"Solo matches played"}},{"groupproperties":{"Ordinal":6,"SortOrder":"Descending","DisplayName":"Wins in solo","DisplayFormat":"Integer"},"xuid":2535431190592405,"scid":"3b040100-2400-45a2-a30c-d45238a4dc9a","name":"Stat-solo-wins","type":"Integer","value":5,"properties":{"DisplayName":"Wins in solo"}},{"groupproperties":{"Ordinal":7,"SortOrder":"Descending","DisplayName":"Wins in squad","DisplayFormat":"Integer"},"xuid":2535431190592405,"scid":"3b040100-2400-45a2-a30c-d45238a4dc9a","name":"Stat-squad-wins","type":"Integer","value":13,"properties":{"DisplayName":"Wins in squad"}},{"groupproperties":{"Ordinal":8,"SortOrder":"Descending","DisplayName":"Wins in duo","DisplayFormat":"Integer"},"xuid":2535431190592405,"scid":"3b040100-2400-45a2-a30c-d45238a4dc9a","name":"Stat-duo-wins","type":"Integer","value":6,"properties":{"DisplayName":"Wins in duo"}}]}]}],"statlistscollection":[{"arrangebyfield":"xuid","arrangebyfieldid":2535431190592405,"stats":[{"groupproperties":[],"xuid":2535431190592405,"scid":"3b040100-2400-45a2-a30c-d45238a4dc9a","titleid":950328474,"name":"MinutesPlayed","type":"Integer","value":16210,"properties":[]}]}]}

kufhjer commented 6 years ago

I am looking at https://docs.microsoft.com/en-us/windows/uwp/xbox-live/xbox-live-rest/uri/atoc-xboxlivews-reference-uris to find a reference to this endpoint but I am unable to find it at this moment.

tuxuser commented 6 years ago

https://docs.microsoft.com/en-us/windows/uwp/xbox-live/xbox-live-rest/uri/userstats/atoc-reference-userstats

It looks pretty complex

kufhjer commented 6 years ago

Yes, I noticed, been doing several test request in the past hour. XboxAPI.com has found a way to do it => https://xboxapi.com/documentation so we should be able to do it as well in my opinion ;) xboxapi.com is using titleId to get the game-stats.

tuxuser commented 6 years ago

Added userstats with 2c49e14

Use the batch function by titleid, it returns most data:

xuid = '1234567890'
# Sea of Thieves Title Id
title_id = 1717113201
resp = xbl_client.userstats.get_stats_batch([xuid], title_id)