fix(people): correct friends list API endpoints and contract version#93
fix(people): correct friends list API endpoints and contract version#93misiektoja wants to merge 3 commits intotr4nt0r:mainfrom
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #93 +/- ##
==========================================
+ Coverage 88.34% 88.35% +0.01%
==========================================
Files 54 54
Lines 2857 2860 +3
==========================================
+ Hits 2524 2527 +3
Misses 333 333 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Not sure if this is the right approach. The Xbox Android app uses a different endpoint/contract version to fetch this data. We should use endpoints and contract versions that are also actively used by the app, otherwise it will be outdated again soon. |
|
Thanks for the feedback! You were absolutely right to push back on downgrading to contract v5. I dug deeper into the API behavior and discovered the real root cause: v7 actually does support fetching friends for other users. The issue was that the original v7 migration in this library used the wrong URL path for get_friends_by_xuid Because this PR became a bit messy with the v5 fallback logic and making the Pydantic model fields Optional, I'm going to close this one out. I've opened a fresh PR (#103) that contains just the single-line URL fix. Thanks again for pointing me in the right direction! |
Hi, I switched my project from xbox-webapi-python to python-xbox and noticed that my code for fetching the list of friends was not working anymore.
It turned out the
get_friends_by_xuid()method was not working correctly:It had a broken URL path
/users/me/people/xuids({xuid})/...which returns the authenticated user's info, not the target user's friends list. The correct path is/users/xuid({xuid})/people/social/...Contract version 7 returns empty results for
get_friends_by_xuid(). When querying another user's friends list, contract v7 returns{"people": []}while v5 returns the actual friends list.I compared behavior across contract versions:
get_friends_ownget_friends_by_xuidI noticed contract v7 was introduced in PR #1 to provide additional relationship fields (
isFriend,canBeFriendedetc.). However, these fields are only returned when querying your OWN friends list -get_friends_by_xuid()returns empty with v7 when querying another user.I implemented usage of different contract versions per method to get the best of both worlds:
get_friends_ownget_friends_by_xuid