python-xbox 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. python_xbox-0.1.0/.gitignore +76 -0
  2. python_xbox-0.1.0/LICENSE +20 -0
  3. python_xbox-0.1.0/PKG-INFO +217 -0
  4. python_xbox-0.1.0/README.md +188 -0
  5. python_xbox-0.1.0/pyproject.toml +125 -0
  6. python_xbox-0.1.0/src/pythonxbox/__init__.py +4 -0
  7. python_xbox-0.1.0/src/pythonxbox/api/__init__.py +0 -0
  8. python_xbox-0.1.0/src/pythonxbox/api/client.py +166 -0
  9. python_xbox-0.1.0/src/pythonxbox/api/language.py +76 -0
  10. python_xbox-0.1.0/src/pythonxbox/api/provider/__init__.py +0 -0
  11. python_xbox-0.1.0/src/pythonxbox/api/provider/account/__init__.py +73 -0
  12. python_xbox-0.1.0/src/pythonxbox/api/provider/account/models.py +11 -0
  13. python_xbox-0.1.0/src/pythonxbox/api/provider/achievements/__init__.py +164 -0
  14. python_xbox-0.1.0/src/pythonxbox/api/provider/achievements/models.py +133 -0
  15. python_xbox-0.1.0/src/pythonxbox/api/provider/baseprovider.py +22 -0
  16. python_xbox-0.1.0/src/pythonxbox/api/provider/catalog/__init__.py +86 -0
  17. python_xbox-0.1.0/src/pythonxbox/api/provider/catalog/const.py +15 -0
  18. python_xbox-0.1.0/src/pythonxbox/api/provider/catalog/models.py +428 -0
  19. python_xbox-0.1.0/src/pythonxbox/api/provider/cqs/__init__.py +85 -0
  20. python_xbox-0.1.0/src/pythonxbox/api/provider/cqs/models.py +59 -0
  21. python_xbox-0.1.0/src/pythonxbox/api/provider/gameclips/__init__.py +167 -0
  22. python_xbox-0.1.0/src/pythonxbox/api/provider/gameclips/models.py +58 -0
  23. python_xbox-0.1.0/src/pythonxbox/api/provider/lists/__init__.py +71 -0
  24. python_xbox-0.1.0/src/pythonxbox/api/provider/lists/models.py +33 -0
  25. python_xbox-0.1.0/src/pythonxbox/api/provider/mediahub/__init__.py +64 -0
  26. python_xbox-0.1.0/src/pythonxbox/api/provider/mediahub/models.py +82 -0
  27. python_xbox-0.1.0/src/pythonxbox/api/provider/message/__init__.py +135 -0
  28. python_xbox-0.1.0/src/pythonxbox/api/provider/message/models.py +96 -0
  29. python_xbox-0.1.0/src/pythonxbox/api/provider/people/__init__.py +193 -0
  30. python_xbox-0.1.0/src/pythonxbox/api/provider/people/models.py +252 -0
  31. python_xbox-0.1.0/src/pythonxbox/api/provider/presence/__init__.py +110 -0
  32. python_xbox-0.1.0/src/pythonxbox/api/provider/presence/models.py +53 -0
  33. python_xbox-0.1.0/src/pythonxbox/api/provider/profile/__init__.py +140 -0
  34. python_xbox-0.1.0/src/pythonxbox/api/provider/profile/models.py +47 -0
  35. python_xbox-0.1.0/src/pythonxbox/api/provider/ratelimitedprovider.py +79 -0
  36. python_xbox-0.1.0/src/pythonxbox/api/provider/screenshots/__init__.py +167 -0
  37. python_xbox-0.1.0/src/pythonxbox/api/provider/screenshots/models.py +56 -0
  38. python_xbox-0.1.0/src/pythonxbox/api/provider/smartglass/__init__.py +402 -0
  39. python_xbox-0.1.0/src/pythonxbox/api/provider/smartglass/models.py +186 -0
  40. python_xbox-0.1.0/src/pythonxbox/api/provider/titlehub/__init__.py +143 -0
  41. python_xbox-0.1.0/src/pythonxbox/api/provider/titlehub/models.py +106 -0
  42. python_xbox-0.1.0/src/pythonxbox/api/provider/usersearch/__init__.py +29 -0
  43. python_xbox-0.1.0/src/pythonxbox/api/provider/usersearch/models.py +17 -0
  44. python_xbox-0.1.0/src/pythonxbox/api/provider/userstats/__init__.py +164 -0
  45. python_xbox-0.1.0/src/pythonxbox/api/provider/userstats/models.py +44 -0
  46. python_xbox-0.1.0/src/pythonxbox/authentication/__init__.py +0 -0
  47. python_xbox-0.1.0/src/pythonxbox/authentication/manager.py +161 -0
  48. python_xbox-0.1.0/src/pythonxbox/authentication/models.py +162 -0
  49. python_xbox-0.1.0/src/pythonxbox/authentication/xal.py +348 -0
  50. python_xbox-0.1.0/src/pythonxbox/common/__init__.py +0 -0
  51. python_xbox-0.1.0/src/pythonxbox/common/exceptions.py +59 -0
  52. python_xbox-0.1.0/src/pythonxbox/common/filetimes.py +81 -0
  53. python_xbox-0.1.0/src/pythonxbox/common/models.py +34 -0
  54. python_xbox-0.1.0/src/pythonxbox/common/ratelimits/__init__.py +268 -0
  55. python_xbox-0.1.0/src/pythonxbox/common/ratelimits/models.py +23 -0
  56. python_xbox-0.1.0/src/pythonxbox/common/request_signer.py +190 -0
  57. python_xbox-0.1.0/src/pythonxbox/common/signed_session.py +60 -0
  58. python_xbox-0.1.0/src/pythonxbox/py.typed +0 -0
  59. python_xbox-0.1.0/src/pythonxbox/scripts/__init__.py +15 -0
  60. python_xbox-0.1.0/src/pythonxbox/scripts/authenticate.py +159 -0
  61. python_xbox-0.1.0/src/pythonxbox/scripts/change_gamertag.py +111 -0
  62. python_xbox-0.1.0/src/pythonxbox/scripts/friends.py +80 -0
  63. python_xbox-0.1.0/src/pythonxbox/scripts/search.py +43 -0
  64. python_xbox-0.1.0/src/pythonxbox/scripts/xal.py +113 -0
@@ -0,0 +1,76 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ .env
12
+ .venv/
13
+ venv/
14
+ build/
15
+ develop-eggs/
16
+ dist/
17
+ downloads/
18
+ eggs/
19
+ .eggs/
20
+ lib/
21
+ lib64/
22
+ parts/
23
+ sdist/
24
+ var/
25
+ *.egg-info/
26
+ .installed.cfg
27
+ *.egg
28
+
29
+ #Virtualenv folders and files
30
+ Scripts
31
+ pyvenv.cfg
32
+ Lib
33
+
34
+ # PyInstaller
35
+ # Usually these files are written by a python script from a template
36
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
37
+ *.manifest
38
+ *.spec
39
+
40
+ # Installer logs
41
+ pip-log.txt
42
+ pip-delete-this-directory.txt
43
+
44
+ # Unit test / coverage reports
45
+ htmlcov/
46
+ .tox/
47
+ .coverage
48
+ .coverage.*
49
+ .cache
50
+ nosetests.xml
51
+ coverage.xml
52
+ *,cover
53
+ .hypothesis/
54
+
55
+ # Translations
56
+ *.mo
57
+ *.pot
58
+
59
+ # Django stuff:
60
+ *.log
61
+
62
+ # Sphinx documentation
63
+ docs/_build/
64
+
65
+ # PyBuilder
66
+ target/
67
+
68
+ # Intellij
69
+ .idea/
70
+
71
+ # VS Code
72
+ .vscode/
73
+
74
+ # Node
75
+ node_modules
76
+
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2025 Manfred Dennerlein Rodelo
2
+ Copyright (c) 2020 - 2025 OpenXbox
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
@@ -0,0 +1,217 @@
1
+ Metadata-Version: 2.4
2
+ Name: python-xbox
3
+ Version: 0.1.0
4
+ Summary: A library to authenticate with Xbox Network and use their API
5
+ Project-URL: Source, https://github.com/tr4nt0r/python-xbox
6
+ Author: OpenXbox
7
+ Author-email: Manfred Dennerlein Rodelo <manfred@dennerlein.name>
8
+ License-Expression: MIT
9
+ License-File: LICENSE
10
+ Keywords: xbox one live api
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: ecdsa
23
+ Requires-Dist: httpx
24
+ Requires-Dist: ms-cv
25
+ Requires-Dist: pydantic==2.*
26
+ Provides-Extra: cli
27
+ Requires-Dist: platformdirs>=4.5.0; extra == 'cli'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # python-xbox
31
+
32
+ [![PyPi - latest](https://img.shields.io/pypi/v/python-xbox.svg)](https://pypi.python.org/pypi/python-xbox/)
33
+ [![Build](https://github.com/tr4nt0r/python-xbox/actions/workflows/build.yml/badge.svg)](https://github.com/tr4nt0r/python-xbox/actions/workflows/build.yml)
34
+ ![PyPI - Downloads](https://img.shields.io/pypi/dm/python-xbox?style=flat&label=pypi%20downloads)
35
+ [!["Buy Me A Coffee"](https://img.shields.io/badge/-buy_me_a%C2%A0coffee-gray?logo=buy-me-a-coffee)](https://www.buymeacoffee.com/tr4nt0r)
36
+ [![GitHub Sponsor](https://img.shields.io/badge/GitHub-Sponsor-blue?logo=github)](https://github.com/sponsors/tr4nt0r)
37
+
38
+ python-xbox is a python library to authenticate with Xbox Network via your Microsoft Account and provides Xbox related Web-API.
39
+
40
+ Authentication is supported via OAuth2.
41
+
42
+ - Register a new application in [Azure AD](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)
43
+ - Name your app
44
+ - Select "Personal Microsoft accounts only" under supported account types
45
+ - Add <http://localhost/auth/callback> as a Redirect URI of type "Web"
46
+ - Copy your Application (client) ID for later use
47
+ - On the App Page, navigate to "Certificates & secrets"
48
+ - Generate a new client secret and save for later use
49
+
50
+ ## Dependencies
51
+
52
+ - Python >= 3.11
53
+
54
+ ## How to use
55
+
56
+ ### Install
57
+
58
+ ```bash
59
+ pip install python-xbox
60
+ ```
61
+
62
+ ### Authentication
63
+
64
+ > [!NOTE]
65
+ > You must use non child account (> 18 years old)
66
+
67
+ Token save location: If tokenfile is not provided via cmdline, fallback of `<platformdirs.user_data_dir>/tokens.json` is used as save-location
68
+
69
+ Specifically:
70
+
71
+ Windows: `C:\\Users\\<username>\\AppData\\Local\\OpenXbox\\xbox`
72
+
73
+ Mac OSX: `/Users/<username>/Library/Application Support/xbox/tokens.json`
74
+
75
+ Linux: `/home/<username>/.local/share/xbox`
76
+
77
+ For more information, see: <https://pypi.org/project/platformdirs> and module: `python-xbox.scripts.constants`
78
+
79
+ ```bash
80
+ xbox-authenticate --client-id <client-id> --client-secret <client-secret>
81
+ ```
82
+
83
+ Example: Search Xbox Live via cmdline tool
84
+
85
+ ```bash
86
+ # Search Xbox One Catalog
87
+ xbox-searchlive "Some game title"
88
+ ```
89
+
90
+ API usage
91
+
92
+ ```python
93
+ import asyncio
94
+ import sys
95
+
96
+ from httpx import HTTPStatusError
97
+
98
+ from pythonxbox.api.client import XboxLiveClient
99
+ from pythonxbox.authentication.manager import AuthenticationManager
100
+ from pythonxbox.authentication.models import OAuth2TokenResponse
101
+ from pythonxbox.common.signed_session import SignedSession
102
+ from pythonxbox.scripts import CLIENT_ID, CLIENT_SECRET, TOKENS_FILE
103
+
104
+ """
105
+ This uses the global default client identification by OpenXbox
106
+ You can supply your own parameters here if you are permitted to create
107
+ new Microsoft OAuth Apps and know what you are doing
108
+ """
109
+ client_id = CLIENT_ID
110
+ client_secret = CLIENT_SECRET
111
+ tokens_file = TOKENS_FILE
112
+
113
+ """
114
+ For doing authentication, see pythonxbox/scripts/authenticate.py
115
+ """
116
+
117
+
118
+ async def async_main():
119
+ # Create a HTTP client session
120
+ async with SignedSession() as session:
121
+ """
122
+ Initialize with global OAUTH parameters from above
123
+ """
124
+ auth_mgr = AuthenticationManager(session, client_id, client_secret, "")
125
+
126
+ """
127
+ Read in tokens that you received from the `xbox-authenticate`-script previously
128
+ See `pythonxbox/scripts/authenticate.py`
129
+ """
130
+ try:
131
+ with open(tokens_file) as f:
132
+ tokens = f.read()
133
+ # Assign gathered tokens
134
+ auth_mgr.oauth = OAuth2TokenResponse.model_validate_json(tokens)
135
+ except FileNotFoundError as e:
136
+ print(
137
+ f"File {tokens_file} isn`t found or it doesn`t contain tokens! err={e}"
138
+ )
139
+ print("Authorizing via OAUTH")
140
+ url = auth_mgr.generate_authorization_url()
141
+ print(f"Auth via URL: {url}")
142
+ authorization_code = input("Enter authorization code> ")
143
+ tokens = await auth_mgr.request_oauth_token(authorization_code)
144
+ auth_mgr.oauth = tokens
145
+
146
+ """
147
+ Refresh tokens, just in case
148
+ You could also manually check the token lifetimes and just refresh them
149
+ if they are close to expiry
150
+ """
151
+ try:
152
+ await auth_mgr.refresh_tokens()
153
+ except HTTPStatusError as e:
154
+ print(
155
+ f"""
156
+ Could not refresh tokens from {tokens_file}, err={e}\n
157
+ You might have to delete the tokens file and re-authenticate
158
+ if refresh token is expired
159
+ """
160
+ )
161
+ sys.exit(-1)
162
+
163
+ # Save the refreshed/updated tokens
164
+ with open(tokens_file, mode="w") as f:
165
+ f.write(auth_mgr.oauth.json())
166
+ print(f"Refreshed tokens in {tokens_file}!")
167
+
168
+ """
169
+ Construct the Xbox API client from AuthenticationManager instance
170
+ """
171
+ xbl_client = XboxLiveClient(auth_mgr)
172
+
173
+ """
174
+ Some example API calls
175
+ """
176
+ # Get friendslist
177
+ friendslist = await xbl_client.people.get_friends_own()
178
+ print(f"Your friends: {friendslist}\n")
179
+
180
+ # Get presence status (by list of XUID)
181
+ presence = await xbl_client.presence.get_presence_batch(
182
+ ["2533274794093122", "2533274807551369"]
183
+ )
184
+ print(f"Statuses of some random players by XUID: {presence}\n")
185
+
186
+ # Get messages
187
+ messages = await xbl_client.message.get_inbox()
188
+ print(f"Your messages: {messages}\n")
189
+
190
+ # Get profile by GT
191
+ profile = await xbl_client.profile.get_profile_by_gamertag("SomeGamertag")
192
+ print(f"Profile under SomeGamertag gamer tag: {profile}\n")
193
+
194
+
195
+ asyncio.run(async_main())
196
+ ```
197
+
198
+ ## Contribute
199
+
200
+ - Report bugs/suggest features
201
+ - Add/update docs
202
+ - Add additional xbox live endpoints
203
+
204
+ ## Credits
205
+
206
+ This library is derived from [xbox-webapi](https://github.com/OpenXbox/xbox-webapi-python) library from the [OpenXbox](https://github.com/openxbox) project
207
+ The authentication code is based on [joealcorn/xbox](https://github.com/joealcorn/xbox)
208
+
209
+ Informations on endpoints gathered from:
210
+
211
+ - [XboxLive REST Reference](https://docs.microsoft.com/en-us/windows/uwp/xbox-live/xbox-live-rest/atoc-xboxlivews-reference)
212
+ - [XboxLiveTraceAnalyzer APIMap](https://github.com/Microsoft/xbox-live-trace-analyzer/blob/master/Source/XboxLiveTraceAnalyzer.APIMap.csv)
213
+ - [Xbox Live Service API](https://github.com/Microsoft/xbox-live-api)
214
+
215
+ ## Disclaimer
216
+
217
+ Xbox, Xbox One, Smartglass and Xbox Live are trademarks of Microsoft Corporation. Team OpenXbox is in no way endorsed by or affiliated with Microsoft Corporation, or any associated subsidiaries, logos or trademarks.
@@ -0,0 +1,188 @@
1
+ # python-xbox
2
+
3
+ [![PyPi - latest](https://img.shields.io/pypi/v/python-xbox.svg)](https://pypi.python.org/pypi/python-xbox/)
4
+ [![Build](https://github.com/tr4nt0r/python-xbox/actions/workflows/build.yml/badge.svg)](https://github.com/tr4nt0r/python-xbox/actions/workflows/build.yml)
5
+ ![PyPI - Downloads](https://img.shields.io/pypi/dm/python-xbox?style=flat&label=pypi%20downloads)
6
+ [!["Buy Me A Coffee"](https://img.shields.io/badge/-buy_me_a%C2%A0coffee-gray?logo=buy-me-a-coffee)](https://www.buymeacoffee.com/tr4nt0r)
7
+ [![GitHub Sponsor](https://img.shields.io/badge/GitHub-Sponsor-blue?logo=github)](https://github.com/sponsors/tr4nt0r)
8
+
9
+ python-xbox is a python library to authenticate with Xbox Network via your Microsoft Account and provides Xbox related Web-API.
10
+
11
+ Authentication is supported via OAuth2.
12
+
13
+ - Register a new application in [Azure AD](https://portal.azure.com/#blade/Microsoft_AAD_RegisteredApps/ApplicationsListBlade)
14
+ - Name your app
15
+ - Select "Personal Microsoft accounts only" under supported account types
16
+ - Add <http://localhost/auth/callback> as a Redirect URI of type "Web"
17
+ - Copy your Application (client) ID for later use
18
+ - On the App Page, navigate to "Certificates & secrets"
19
+ - Generate a new client secret and save for later use
20
+
21
+ ## Dependencies
22
+
23
+ - Python >= 3.11
24
+
25
+ ## How to use
26
+
27
+ ### Install
28
+
29
+ ```bash
30
+ pip install python-xbox
31
+ ```
32
+
33
+ ### Authentication
34
+
35
+ > [!NOTE]
36
+ > You must use non child account (> 18 years old)
37
+
38
+ Token save location: If tokenfile is not provided via cmdline, fallback of `<platformdirs.user_data_dir>/tokens.json` is used as save-location
39
+
40
+ Specifically:
41
+
42
+ Windows: `C:\\Users\\<username>\\AppData\\Local\\OpenXbox\\xbox`
43
+
44
+ Mac OSX: `/Users/<username>/Library/Application Support/xbox/tokens.json`
45
+
46
+ Linux: `/home/<username>/.local/share/xbox`
47
+
48
+ For more information, see: <https://pypi.org/project/platformdirs> and module: `python-xbox.scripts.constants`
49
+
50
+ ```bash
51
+ xbox-authenticate --client-id <client-id> --client-secret <client-secret>
52
+ ```
53
+
54
+ Example: Search Xbox Live via cmdline tool
55
+
56
+ ```bash
57
+ # Search Xbox One Catalog
58
+ xbox-searchlive "Some game title"
59
+ ```
60
+
61
+ API usage
62
+
63
+ ```python
64
+ import asyncio
65
+ import sys
66
+
67
+ from httpx import HTTPStatusError
68
+
69
+ from pythonxbox.api.client import XboxLiveClient
70
+ from pythonxbox.authentication.manager import AuthenticationManager
71
+ from pythonxbox.authentication.models import OAuth2TokenResponse
72
+ from pythonxbox.common.signed_session import SignedSession
73
+ from pythonxbox.scripts import CLIENT_ID, CLIENT_SECRET, TOKENS_FILE
74
+
75
+ """
76
+ This uses the global default client identification by OpenXbox
77
+ You can supply your own parameters here if you are permitted to create
78
+ new Microsoft OAuth Apps and know what you are doing
79
+ """
80
+ client_id = CLIENT_ID
81
+ client_secret = CLIENT_SECRET
82
+ tokens_file = TOKENS_FILE
83
+
84
+ """
85
+ For doing authentication, see pythonxbox/scripts/authenticate.py
86
+ """
87
+
88
+
89
+ async def async_main():
90
+ # Create a HTTP client session
91
+ async with SignedSession() as session:
92
+ """
93
+ Initialize with global OAUTH parameters from above
94
+ """
95
+ auth_mgr = AuthenticationManager(session, client_id, client_secret, "")
96
+
97
+ """
98
+ Read in tokens that you received from the `xbox-authenticate`-script previously
99
+ See `pythonxbox/scripts/authenticate.py`
100
+ """
101
+ try:
102
+ with open(tokens_file) as f:
103
+ tokens = f.read()
104
+ # Assign gathered tokens
105
+ auth_mgr.oauth = OAuth2TokenResponse.model_validate_json(tokens)
106
+ except FileNotFoundError as e:
107
+ print(
108
+ f"File {tokens_file} isn`t found or it doesn`t contain tokens! err={e}"
109
+ )
110
+ print("Authorizing via OAUTH")
111
+ url = auth_mgr.generate_authorization_url()
112
+ print(f"Auth via URL: {url}")
113
+ authorization_code = input("Enter authorization code> ")
114
+ tokens = await auth_mgr.request_oauth_token(authorization_code)
115
+ auth_mgr.oauth = tokens
116
+
117
+ """
118
+ Refresh tokens, just in case
119
+ You could also manually check the token lifetimes and just refresh them
120
+ if they are close to expiry
121
+ """
122
+ try:
123
+ await auth_mgr.refresh_tokens()
124
+ except HTTPStatusError as e:
125
+ print(
126
+ f"""
127
+ Could not refresh tokens from {tokens_file}, err={e}\n
128
+ You might have to delete the tokens file and re-authenticate
129
+ if refresh token is expired
130
+ """
131
+ )
132
+ sys.exit(-1)
133
+
134
+ # Save the refreshed/updated tokens
135
+ with open(tokens_file, mode="w") as f:
136
+ f.write(auth_mgr.oauth.json())
137
+ print(f"Refreshed tokens in {tokens_file}!")
138
+
139
+ """
140
+ Construct the Xbox API client from AuthenticationManager instance
141
+ """
142
+ xbl_client = XboxLiveClient(auth_mgr)
143
+
144
+ """
145
+ Some example API calls
146
+ """
147
+ # Get friendslist
148
+ friendslist = await xbl_client.people.get_friends_own()
149
+ print(f"Your friends: {friendslist}\n")
150
+
151
+ # Get presence status (by list of XUID)
152
+ presence = await xbl_client.presence.get_presence_batch(
153
+ ["2533274794093122", "2533274807551369"]
154
+ )
155
+ print(f"Statuses of some random players by XUID: {presence}\n")
156
+
157
+ # Get messages
158
+ messages = await xbl_client.message.get_inbox()
159
+ print(f"Your messages: {messages}\n")
160
+
161
+ # Get profile by GT
162
+ profile = await xbl_client.profile.get_profile_by_gamertag("SomeGamertag")
163
+ print(f"Profile under SomeGamertag gamer tag: {profile}\n")
164
+
165
+
166
+ asyncio.run(async_main())
167
+ ```
168
+
169
+ ## Contribute
170
+
171
+ - Report bugs/suggest features
172
+ - Add/update docs
173
+ - Add additional xbox live endpoints
174
+
175
+ ## Credits
176
+
177
+ This library is derived from [xbox-webapi](https://github.com/OpenXbox/xbox-webapi-python) library from the [OpenXbox](https://github.com/openxbox) project
178
+ The authentication code is based on [joealcorn/xbox](https://github.com/joealcorn/xbox)
179
+
180
+ Informations on endpoints gathered from:
181
+
182
+ - [XboxLive REST Reference](https://docs.microsoft.com/en-us/windows/uwp/xbox-live/xbox-live-rest/atoc-xboxlivews-reference)
183
+ - [XboxLiveTraceAnalyzer APIMap](https://github.com/Microsoft/xbox-live-trace-analyzer/blob/master/Source/XboxLiveTraceAnalyzer.APIMap.csv)
184
+ - [Xbox Live Service API](https://github.com/Microsoft/xbox-live-api)
185
+
186
+ ## Disclaimer
187
+
188
+ Xbox, Xbox One, Smartglass and Xbox Live are trademarks of Microsoft Corporation. Team OpenXbox is in no way endorsed by or affiliated with Microsoft Corporation, or any associated subsidiaries, logos or trademarks.
@@ -0,0 +1,125 @@
1
+ [project]
2
+ name = "python-xbox"
3
+ description = "A library to authenticate with Xbox Network and use their API"
4
+ authors = [
5
+ {name = "Manfred Dennerlein Rodelo", email = "manfred@dennerlein.name"},
6
+ {name = "OpenXbox"},
7
+ ]
8
+ dependencies = [
9
+ "ecdsa",
10
+ "httpx",
11
+ "ms_cv",
12
+ "pydantic==2.*",
13
+ ]
14
+ requires-python = ">=3.11"
15
+ readme = "README.md"
16
+ license = "MIT"
17
+ keywords = ["xbox one live api"]
18
+ classifiers = [
19
+ "Development Status :: 5 - Production/Stable",
20
+ "Intended Audience :: Developers",
21
+ "License :: OSI Approved :: MIT License",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.11",
24
+ "Programming Language :: Python :: 3.12",
25
+ "Programming Language :: Python :: 3.13",
26
+ "Programming Language :: Python :: 3.14",
27
+ "Operating System :: OS Independent",
28
+ "Topic :: Software Development :: Libraries :: Python Modules",
29
+ ]
30
+ dynamic = ["version"]
31
+
32
+ [project.urls]
33
+ Source = "https://github.com/tr4nt0r/python-xbox"
34
+
35
+ [project.optional-dependencies]
36
+ cli = [
37
+ "platformdirs>=4.5.0"
38
+ ]
39
+
40
+ [project.scripts]
41
+ xbox-authenticate = "pythonxbox.scripts.authenticate:main"
42
+ xbox-change-gt = "pythonxbox.scripts.change_gamertag:main"
43
+ xbox-friends = "pythonxbox.scripts.friends:main"
44
+ xbox-searchlive = "pythonxbox.scripts.search:main"
45
+ xbox-xal = "pythonxbox.scripts.xal:main"
46
+
47
+ [tool.ruff]
48
+ line-length = 88
49
+ target-version = "py311"
50
+
51
+ [tool.ruff.lint]
52
+ select = ["E4", "E7", "E9", "F", "UP", "S", "ANN"]
53
+ # select = ["ALL"]
54
+ ignore = ["ANN003", "ANN401"]
55
+
56
+
57
+ [tool.ruff.lint.per-file-ignores]
58
+ "**/scripts/*" = ["UP", "S104"]
59
+ "tests/*" = ["S101"]
60
+ "src/pythonxbox/authentication/xal.py" = ["S101"]
61
+
62
+ [tool.ruff.lint.isort]
63
+ force-sort-within-sections = true
64
+ known-first-party = ["pythonxbox"]
65
+ combine-as-imports = true
66
+ split-on-trailing-comma = false
67
+
68
+ [tool.ruff.format]
69
+ quote-style = "double"
70
+ indent-style = "space"
71
+
72
+ [tool.hatch.version]
73
+ source = "regex_commit"
74
+ commit_extra_args = ["-e"]
75
+ path = "src/pythonxbox/__init__.py"
76
+
77
+ [tool.hatch.build.targets.sdist]
78
+ include = [
79
+ "src/pythonxbox",
80
+ ]
81
+ [tool.hatch.build.targets.wheel]
82
+ packages = ["src/pythonxbox"]
83
+
84
+ [tool.hatch.envs.default]
85
+ python = "3.13"
86
+ dependencies = [
87
+ "platformdirs==4.5.0",
88
+ "ecdsa==0.19.1",
89
+ "httpx==0.28.1",
90
+ "ms_cv==0.1.1",
91
+ "pydantic==2.12.3",
92
+ "pytest==8.4.2",
93
+ "pytest-asyncio==1.2.0",
94
+ "pytest-cov==7.0.0",
95
+ "freezegun==1.5.5",
96
+ "respx~=0.22",
97
+ ]
98
+
99
+ [tool.hatch.envs.hatch-test]
100
+ parallel = true
101
+ extra-dependencies = [
102
+ "pytest-cov~=6.2",
103
+ "pytest-asyncio~=1.1",
104
+ "respx~=0.22",
105
+ "freezegun==1.5.5"
106
+ ]
107
+ extra-args = ["--cov=src/", "--cov-report=term-missing", "--cov-report=xml", "-vv"]
108
+
109
+ [tool.pytest.ini_options]
110
+ asyncio_mode = "auto"
111
+ testpaths = ["tests"]
112
+ pythonpath = ["src"]
113
+
114
+ [[tool.hatch.envs.hatch-test.matrix]]
115
+ python = ["3.14", "3.13", "3.12", "3.11"]
116
+
117
+ [tool.hatch.envs.hatch-static-analysis]
118
+ dependencies = [
119
+ "ruff==0.14.2",
120
+ ]
121
+ config-path = "none"
122
+
123
+ [build-system]
124
+ requires = ["hatchling", "hatch-regex-commit"]
125
+ build-backend = "hatchling.build"
@@ -0,0 +1,4 @@
1
+ """Top-level package for python-xbox."""
2
+
3
+ __author__ = """tr4nt0r"""
4
+ __version__ = "0.1.0"
File without changes