Skip to content

fix(people): correct friends list API endpoints and contract version#93

Closed
misiektoja wants to merge 3 commits intotr4nt0r:mainfrom
misiektoja:friends-list-fix
Closed

fix(people): correct friends list API endpoints and contract version#93
misiektoja wants to merge 3 commits intotr4nt0r:mainfrom
misiektoja:friends-list-fix

Conversation

@misiektoja
Copy link
Contributor

@misiektoja misiektoja commented Feb 7, 2026

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:

  1. 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/...

  2. 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:

Version get_friends_own get_friends_by_xuid
v3 (original xbox-webapi) OK OK
v5 OK OK
v7 OK NOT OK

I noticed contract v7 was introduced in PR #1 to provide additional relationship fields (isFriend, canBeFriended etc.). 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:

Method Contract Version Reason
get_friends_own v7 Full relationship fields
get_friends_by_xuid v5 v7 returns empty for other users

@github-actions github-actions bot added the 👻 bug Something isn't working label Feb 7, 2026
@github-actions github-actions bot added the 🧪 testing Pull request that adds tests label Feb 7, 2026
@codecov
Copy link

codecov bot commented Feb 9, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.35%. Comparing base (132b2be) to head (6243bc5).
⚠️ Report is 9 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tr4nt0r
Copy link
Owner

tr4nt0r commented Feb 25, 2026

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.

@misiektoja
Copy link
Contributor Author

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
(/users/me/people/xuids({xuid})/ instead of /users/xuid({xuid})/people/friends/).

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!

@misiektoja misiektoja closed this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👻 bug Something isn't working 🧪 testing Pull request that adds tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants