blizzardapi2 3.0.4__tar.gz → 4.0.1__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.
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/.gitignore +10 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/.release-it.json +6 -1
- {blizzardapi2-3.0.4/blizzardapi2.egg-info → blizzardapi2-4.0.1}/PKG-INFO +2 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/api.py +66 -36
- blizzardapi2-4.0.1/blizzardapi2/battlenet/battlenet_api.py +19 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/battlenet/battlenet_oauth_api.py +6 -24
- blizzardapi2-4.0.1/blizzardapi2/blizzard_api.py +42 -0
- blizzardapi2-4.0.1/blizzardapi2/diablo3/diablo3_api.py +31 -0
- blizzardapi2-4.0.1/blizzardapi2/diablo3/diablo3_community_api.py +315 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/diablo3/diablo3_game_data_api.py +20 -24
- blizzardapi2-4.0.1/blizzardapi2/endpoint.py +81 -0
- blizzardapi2-4.0.1/blizzardapi2/hearthstone/hearthstone_api.py +38 -0
- blizzardapi2-4.0.1/blizzardapi2/hearthstone/hearthstone_game_data_api.py +170 -0
- blizzardapi2-4.0.1/blizzardapi2/starcraft2/starcraft2_api.py +29 -0
- blizzardapi2-4.0.1/blizzardapi2/starcraft2/starcraft2_community_api.py +209 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/starcraft2/starcraft2_game_data_api.py +10 -13
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/types.py +7 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/wow/wow_api.py +10 -14
- blizzardapi2-4.0.1/blizzardapi2/wow/wow_game_data_api.py +3181 -0
- blizzardapi2-4.0.1/blizzardapi2/wow/wow_profile_api.py +1098 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1/blizzardapi2.egg-info}/PKG-INFO +2 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2.egg-info/SOURCES.txt +2 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2.egg-info/requires.txt +1 -0
- blizzardapi2-4.0.1/package-lock.json +4407 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/package.json +2 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/pyproject.toml +2 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/tests/test_base_api.py +165 -3
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/tests/test_battlenet.py +23 -8
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/tests/test_diablo3.py +7 -7
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/tests/test_hearthstone.py +12 -15
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/tests/test_starcraft2.py +2 -7
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/tests/test_wow.py +90 -7
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/uv.lock +12 -1
- blizzardapi2-3.0.4/blizzardapi2/battlenet/battlenet_api.py +0 -16
- blizzardapi2-3.0.4/blizzardapi2/blizzard_api.py +0 -64
- blizzardapi2-3.0.4/blizzardapi2/diablo3/diablo3_api.py +0 -36
- blizzardapi2-3.0.4/blizzardapi2/diablo3/diablo3_community_api.py +0 -272
- blizzardapi2-3.0.4/blizzardapi2/hearthstone/hearthstone_api.py +0 -52
- blizzardapi2-3.0.4/blizzardapi2/hearthstone/hearthstone_game_data_api.py +0 -156
- blizzardapi2-3.0.4/blizzardapi2/starcraft2/starcraft2_api.py +0 -22
- blizzardapi2-3.0.4/blizzardapi2/starcraft2/starcraft2_community_api.py +0 -188
- blizzardapi2-3.0.4/blizzardapi2/wow/wow_game_data_api.py +0 -2720
- blizzardapi2-3.0.4/blizzardapi2/wow/wow_profile_api.py +0 -862
- blizzardapi2-3.0.4/poetry.lock +0 -377
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/.github/dependabot.yml +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/.github/workflows/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/.github/workflows/black-check.yml +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/.github/workflows/python-package.yml +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/.pre-commit-config.yaml +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/CLAUDE.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/CODE_OF_CONDUCT.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/CONTRIBUTING.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/LICENSE +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/SECURITY.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/battlenet/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/diablo3/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/hearthstone/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/starcraft2/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2/wow/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2.egg-info/dependency_links.txt +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/blizzardapi2.egg-info/top_level.txt +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/docs/battlenet/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/docs/diablo3/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/docs/hearthstone/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/docs/pull_request_template.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/docs/starcraft2/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/docs/wow/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/setup.cfg +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/tests/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/tests/conftest.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.1}/tests/test_types.py +0 -0
|
@@ -141,4 +141,13 @@ dmypy.json
|
|
|
141
141
|
test_project/
|
|
142
142
|
|
|
143
143
|
# Version file
|
|
144
|
-
blizzardapi2/_version.py
|
|
144
|
+
blizzardapi2/_version.py
|
|
145
|
+
|
|
146
|
+
# Poetry lock file (project uses uv instead of poetry for CI)
|
|
147
|
+
poetry.lock
|
|
148
|
+
|
|
149
|
+
# Dev-time diff artifacts
|
|
150
|
+
*.patch
|
|
151
|
+
|
|
152
|
+
# Node deps for release-it tooling
|
|
153
|
+
node_modules/
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"github": {
|
|
7
7
|
"release": true,
|
|
8
8
|
"releaseName": "Release v${version}",
|
|
9
|
-
"releaseNotes": "
|
|
9
|
+
"releaseNotes": "${changelog}"
|
|
10
10
|
},
|
|
11
11
|
"npm": {
|
|
12
12
|
"publish": false
|
|
@@ -15,5 +15,10 @@
|
|
|
15
15
|
"after:bump": [
|
|
16
16
|
"sed -i 's/^version = \".*\"/version = \"${version}\"/' pyproject.toml"
|
|
17
17
|
]
|
|
18
|
+
},
|
|
19
|
+
"plugins": {
|
|
20
|
+
"@release-it/conventional-changelog": {
|
|
21
|
+
"preset": "conventionalcommits"
|
|
22
|
+
}
|
|
18
23
|
}
|
|
19
24
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blizzardapi2
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.1
|
|
4
4
|
Summary: A Python wrapper for Blizzard API
|
|
5
5
|
Author-email: lostcol0ny <c098os0k@4wrd.cc>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -18,6 +18,7 @@ Requires-Dist: pytest<10.0.0,>=8.2.2; extra == "dev"
|
|
|
18
18
|
Requires-Dist: pytest-mock<4.0.0,>=3.14.0; extra == "dev"
|
|
19
19
|
Requires-Dist: pytest-asyncio<2.0.0,>=0.23.5; extra == "dev"
|
|
20
20
|
Requires-Dist: black<27.0.0,>=26.3.1; extra == "dev"
|
|
21
|
+
Requires-Dist: isort<9.0.0,>=8.0.1; extra == "dev"
|
|
21
22
|
Requires-Dist: ruff<1.0.0,>=0.3.0; extra == "dev"
|
|
22
23
|
Requires-Dist: build<2.0.0,>=1.2.0; extra == "dev"
|
|
23
24
|
Requires-Dist: twine<7.0.0,>=5.0.0; extra == "dev"
|
|
@@ -5,19 +5,15 @@ from typing import Any, Optional
|
|
|
5
5
|
|
|
6
6
|
import requests
|
|
7
7
|
|
|
8
|
+
from .endpoint import ApiEndpoint
|
|
9
|
+
from .types import Locale, OptionalLocale, OptionalRegion, Region
|
|
8
10
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
|
|
12
|
+
class BaseApi(ApiEndpoint):
|
|
13
|
+
"""Shared API services for Blizzard API clients.
|
|
11
14
|
|
|
12
15
|
Provides common functionality for authentication, token management,
|
|
13
16
|
and HTTP requests to Blizzard APIs.
|
|
14
|
-
|
|
15
|
-
Attributes:
|
|
16
|
-
_client_id: Blizzard API client ID.
|
|
17
|
-
_client_secret: Blizzard API client secret.
|
|
18
|
-
_access_token: Current access token for API requests.
|
|
19
|
-
_token_expires_at: Token expiration timestamp as datetime object.
|
|
20
|
-
_session: HTTP session for making requests.
|
|
21
17
|
"""
|
|
22
18
|
|
|
23
19
|
# Region-specific URL mappings
|
|
@@ -39,15 +35,7 @@ class BaseApi:
|
|
|
39
35
|
DEFAULT_GET_TIMEOUT = 30.0
|
|
40
36
|
DEFAULT_POST_TIMEOUT = 10.0
|
|
41
37
|
|
|
42
|
-
def
|
|
43
|
-
"""Initialize the API client.
|
|
44
|
-
|
|
45
|
-
Args:
|
|
46
|
-
client_id: Blizzard API client ID.
|
|
47
|
-
client_secret: Blizzard API client secret.
|
|
48
|
-
"""
|
|
49
|
-
self._client_id = client_id
|
|
50
|
-
self._client_secret = client_secret
|
|
38
|
+
def extend_endpoint(self) -> None:
|
|
51
39
|
self._access_token: Optional[str] = None
|
|
52
40
|
self._token_expires_at: Optional[datetime] = None
|
|
53
41
|
self._session = requests.Session()
|
|
@@ -62,7 +50,7 @@ class BaseApi:
|
|
|
62
50
|
"""Fetch an access token using client credentials flow.
|
|
63
51
|
|
|
64
52
|
Args:
|
|
65
|
-
region: The region
|
|
53
|
+
region: The region to query (e.g., us, eu, kr, tw, cn). Defaults to None, in which case the default region provided at instantiation is used.
|
|
66
54
|
|
|
67
55
|
Returns:
|
|
68
56
|
The token response from the API.
|
|
@@ -71,7 +59,7 @@ class BaseApi:
|
|
|
71
59
|
response = self._session.post(
|
|
72
60
|
url,
|
|
73
61
|
params={"grant_type": "client_credentials"},
|
|
74
|
-
auth=(self.
|
|
62
|
+
auth=(self.client_id, self._client_secret),
|
|
75
63
|
timeout=self.DEFAULT_POST_TIMEOUT,
|
|
76
64
|
)
|
|
77
65
|
response.raise_for_status()
|
|
@@ -89,12 +77,12 @@ class BaseApi:
|
|
|
89
77
|
if self._access_token is None or self._is_token_expired():
|
|
90
78
|
self._get_client_token(region)
|
|
91
79
|
|
|
92
|
-
def _build_oauth_url(self, resource: str, region: str) -> str:
|
|
80
|
+
def _build_oauth_url(self, resource: str, region: Region | str) -> str:
|
|
93
81
|
"""Build URL for OAuth endpoints.
|
|
94
82
|
|
|
95
83
|
Args:
|
|
96
84
|
resource: The API resource path.
|
|
97
|
-
region: The region (us, eu, kr, tw, cn).
|
|
85
|
+
region: The region to query (e.g., us, eu, kr, tw, cn). Defaults to None, in which case the default region provided at instantiation is used.
|
|
98
86
|
|
|
99
87
|
Returns:
|
|
100
88
|
The complete OAuth URL.
|
|
@@ -107,15 +95,14 @@ class BaseApi:
|
|
|
107
95
|
|
|
108
96
|
Args:
|
|
109
97
|
resource: The API resource path.
|
|
110
|
-
region: The region (us, eu, kr, tw, cn).
|
|
98
|
+
region: The region to query (e.g., us, eu, kr, tw, cn). Defaults to None, in which case the default region provided at instantiation is used.
|
|
111
99
|
|
|
112
100
|
Returns:
|
|
113
101
|
The complete API URL.
|
|
114
102
|
"""
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
base_url = self.API_URLS["default"].format(region=region)
|
|
103
|
+
base_url = self.API_URLS.get(
|
|
104
|
+
region, self.API_URLS["default"].format(region=region)
|
|
105
|
+
)
|
|
119
106
|
return f"{base_url}{resource}"
|
|
120
107
|
|
|
121
108
|
def _make_request(
|
|
@@ -128,7 +115,7 @@ class BaseApi:
|
|
|
128
115
|
|
|
129
116
|
Args:
|
|
130
117
|
url: The complete URL to request.
|
|
131
|
-
region: The region
|
|
118
|
+
region: The region to query (e.g., us, eu, kr, tw, cn). Defaults to None, in which case the default region provided at instantiation is used.
|
|
132
119
|
query_params: Optional query parameters.
|
|
133
120
|
|
|
134
121
|
Returns:
|
|
@@ -172,33 +159,76 @@ class BaseApi:
|
|
|
172
159
|
return response.json()
|
|
173
160
|
|
|
174
161
|
def get_resource(
|
|
175
|
-
self,
|
|
162
|
+
self,
|
|
163
|
+
resource: str,
|
|
164
|
+
region: OptionalRegion = None,
|
|
165
|
+
query_params: Optional[dict[str, Any]] = None,
|
|
176
166
|
) -> dict[str, Any]:
|
|
177
167
|
"""Make a request to a regular API resource.
|
|
178
168
|
|
|
179
169
|
Args:
|
|
180
170
|
resource: The API resource path.
|
|
181
|
-
region:
|
|
171
|
+
region (Region, optional): the region to query (e.g., Region.US, Region.EU). Defaults to None, in which case the default region provided at instantiation is used.
|
|
182
172
|
query_params: Optional query parameters.
|
|
183
173
|
|
|
184
174
|
Returns:
|
|
185
175
|
The API response as a dictionary.
|
|
186
176
|
"""
|
|
187
|
-
|
|
188
|
-
|
|
177
|
+
_region = Region(region or self.region)
|
|
178
|
+
url = self._build_api_url(resource, _region)
|
|
179
|
+
return self._make_request(url, _region, query_params)
|
|
189
180
|
|
|
190
181
|
def get_oauth_resource(
|
|
191
|
-
self,
|
|
182
|
+
self,
|
|
183
|
+
resource: str,
|
|
184
|
+
region: OptionalRegion = None,
|
|
185
|
+
query_params: Optional[dict[str, Any]] = None,
|
|
192
186
|
) -> dict[str, Any]:
|
|
193
187
|
"""Make a request to an OAuth API resource.
|
|
194
188
|
|
|
195
189
|
Args:
|
|
196
190
|
resource: The API resource path.
|
|
197
|
-
region:
|
|
191
|
+
region (Region, optional): the region to query (e.g., Region.US, Region.EU). Defaults to None, in which case the default region provided at instantiation is used.
|
|
192
|
+
query_params: Optional query parameters.
|
|
193
|
+
|
|
194
|
+
Returns:
|
|
195
|
+
The API response as a dictionary.
|
|
196
|
+
"""
|
|
197
|
+
_region = Region(region or self.region)
|
|
198
|
+
url = self._build_oauth_url(resource, _region)
|
|
199
|
+
return self._make_request(url, _region, query_params)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
class LocaleApi(BaseApi):
|
|
203
|
+
"""Locale-aware API class for Blizzard API clients.
|
|
204
|
+
|
|
205
|
+
Extends the base API to handle locale-aware services
|
|
206
|
+
"""
|
|
207
|
+
|
|
208
|
+
def get_resource(
|
|
209
|
+
self,
|
|
210
|
+
resource: str,
|
|
211
|
+
region: OptionalRegion = None,
|
|
212
|
+
query_params: Optional[dict[str, Any]] = None,
|
|
213
|
+
*,
|
|
214
|
+
locale: OptionalLocale = None,
|
|
215
|
+
) -> dict[str, Any]:
|
|
216
|
+
"""Make a request to a locale-aware API resource.
|
|
217
|
+
|
|
218
|
+
Args:
|
|
219
|
+
resource: The API resource path.
|
|
220
|
+
region (Region, optional): the region to query (e.g., Region.US, Region.EU). Defaults to None, in which case the default region provided at instantiation is used.
|
|
198
221
|
query_params: Optional query parameters.
|
|
222
|
+
locale (Locale, optional, keyword-only): the locale to use for the response (e.g., Locale.ES_MX, Locale.DE_DE). Defaults to None, in which case the default locale provided at instantiation is used.
|
|
199
223
|
|
|
200
224
|
Returns:
|
|
201
225
|
The API response as a dictionary.
|
|
202
226
|
"""
|
|
203
|
-
|
|
204
|
-
|
|
227
|
+
# Allow the locale in the query_params (if any) to override any other
|
|
228
|
+
# locale provided (explicitly or by default). Copy the dict so we don't
|
|
229
|
+
# mutate the caller's — repeated calls with a shared dict would otherwise
|
|
230
|
+
# accumulate baked-in locale values.
|
|
231
|
+
_query_params = (query_params or {}).copy()
|
|
232
|
+
if _query_params.get("locale") is None:
|
|
233
|
+
_query_params["locale"] = Locale(locale or self.locale)
|
|
234
|
+
return super().get_resource(resource, region=region, query_params=_query_params)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"""battlenet_api.py file."""
|
|
2
|
+
|
|
3
|
+
from ..endpoint import ApiEndpoint
|
|
4
|
+
from .battlenet_oauth_api import BattlenetOAuthApi
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class BattlenetApi(ApiEndpoint):
|
|
8
|
+
"""Battle.net API class.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
client_id (str): A string client id supplied by Blizzard.
|
|
12
|
+
client_secret (str): A string client secret supplied by Blizzard.
|
|
13
|
+
region (Region, optional): Default region to use for requests.
|
|
14
|
+
oauth (BattlenetOAuthApi): An instance of the BattlenetOAuthApi class for accessing OAuth endpoints.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def extend_endpoint(self) -> None:
|
|
18
|
+
"""Init BattlenetApi."""
|
|
19
|
+
self.oauth = BattlenetOAuthApi(self.client_id, self.client_secret, self.region)
|
|
@@ -4,19 +4,10 @@ This module provides access to Battle.net OAuth endpoints,
|
|
|
4
4
|
including user information and authentication.
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
|
-
from typing import Any
|
|
7
|
+
from typing import Any
|
|
8
8
|
|
|
9
9
|
from ..api import BaseApi
|
|
10
|
-
from ..types import
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
class ApiResponse:
|
|
14
|
-
"""Wrapper for API responses with metadata."""
|
|
15
|
-
|
|
16
|
-
data: Dict[str, Any]
|
|
17
|
-
region: Region
|
|
18
|
-
locale: Locale
|
|
19
|
-
namespace: str
|
|
10
|
+
from ..types import OptionalRegion
|
|
20
11
|
|
|
21
12
|
|
|
22
13
|
class BattlenetOAuthApi(BaseApi):
|
|
@@ -31,23 +22,14 @@ class BattlenetOAuthApi(BaseApi):
|
|
|
31
22
|
_client_secret: The Blizzard API client secret.
|
|
32
23
|
"""
|
|
33
24
|
|
|
34
|
-
def
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Args:
|
|
38
|
-
client_id: The Blizzard API client ID.
|
|
39
|
-
client_secret: The Blizzard API client secret.
|
|
40
|
-
"""
|
|
41
|
-
super().__init__(client_id, client_secret)
|
|
42
|
-
|
|
43
|
-
def get_user_info(self, region: Region | str, access_token: str) -> dict[str, Any]:
|
|
25
|
+
def get_user_info(
|
|
26
|
+
self, access_token: str, *, region: OptionalRegion = None
|
|
27
|
+
) -> dict[str, Any]:
|
|
44
28
|
"""Get basic information about the user associated with the current bearer token.
|
|
45
29
|
|
|
46
30
|
Args:
|
|
47
|
-
region: The region to query — either a ``Region`` enum member or
|
|
48
|
-
a bare string (e.g. ``"us"`` or ``Region.US``). Bare strings
|
|
49
|
-
are accepted for ergonomics and parity with the other game APIs.
|
|
50
31
|
access_token: The OAuth access token.
|
|
32
|
+
region (Region, optional): the region to query (e.g., Region.US, Region.EU). Defaults to None, in which case the default region provided at instantiation is used.
|
|
51
33
|
|
|
52
34
|
Returns:
|
|
53
35
|
A dictionary containing user information.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"""Main entry point for the Blizzard API client.
|
|
2
|
+
|
|
3
|
+
This module provides a unified interface to all Blizzard game APIs through
|
|
4
|
+
a single client instance. Each game's API is accessible through its own
|
|
5
|
+
property on the main client.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from .battlenet.battlenet_api import BattlenetApi
|
|
9
|
+
from .diablo3.diablo3_api import Diablo3Api
|
|
10
|
+
from .endpoint import ApiEndpoint
|
|
11
|
+
from .hearthstone.hearthstone_api import HearthstoneApi
|
|
12
|
+
from .starcraft2.starcraft2_api import Starcraft2Api
|
|
13
|
+
from .wow.wow_api import WowApi
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class BlizzardApi(ApiEndpoint):
|
|
17
|
+
"""Blizzard API client.
|
|
18
|
+
|
|
19
|
+
This class provides access to all Blizzard game APIs through a unified
|
|
20
|
+
interface. It organizes access to individual game APIs through their
|
|
21
|
+
respective components.
|
|
22
|
+
|
|
23
|
+
Attributes:
|
|
24
|
+
wow: The World of Warcraft API client.
|
|
25
|
+
diablo3: The Diablo III API client.
|
|
26
|
+
hearthstone: The Hearthstone API client.
|
|
27
|
+
starcraft2: The StarCraft II API client.
|
|
28
|
+
battlenet: The Battle.net API client.
|
|
29
|
+
"""
|
|
30
|
+
|
|
31
|
+
def extend_endpoint(self) -> None:
|
|
32
|
+
self.wow = WowApi(self.client_id, self.client_secret, self.region, self.locale)
|
|
33
|
+
self.diablo3 = Diablo3Api(
|
|
34
|
+
self.client_id, self.client_secret, self.region, self.locale
|
|
35
|
+
)
|
|
36
|
+
self.hearthstone = HearthstoneApi(
|
|
37
|
+
self.client_id, self.client_secret, self.region, self.locale
|
|
38
|
+
)
|
|
39
|
+
self.starcraft2 = Starcraft2Api(
|
|
40
|
+
self.client_id, self.client_secret, self.region, self.locale
|
|
41
|
+
)
|
|
42
|
+
self.battlenet = BattlenetApi(self.client_id, self.client_secret, self.region)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"""Diablo III API client.
|
|
2
|
+
|
|
3
|
+
This module provides access to the Diablo III API endpoints,
|
|
4
|
+
including game data and community information.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from blizzardapi2.endpoint import ApiEndpoint
|
|
8
|
+
|
|
9
|
+
from .diablo3_community_api import Diablo3CommunityApi
|
|
10
|
+
from .diablo3_game_data_api import Diablo3GameDataApi
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class Diablo3Api(ApiEndpoint):
|
|
14
|
+
"""Diablo III API client.
|
|
15
|
+
|
|
16
|
+
This class provides access to all Diablo III API endpoints.
|
|
17
|
+
It organizes access to community and game data functionality through
|
|
18
|
+
the Diablo3CommunityApi and Diablo3GameDataApi components.
|
|
19
|
+
|
|
20
|
+
Attributes:
|
|
21
|
+
community: The community API client.
|
|
22
|
+
game_data: The game data API client.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
def extend_endpoint(self) -> None:
|
|
26
|
+
self.community = Diablo3CommunityApi(
|
|
27
|
+
self.client_id, self.client_secret, self.region, self.locale
|
|
28
|
+
)
|
|
29
|
+
self.game_data = Diablo3GameDataApi(
|
|
30
|
+
self.client_id, self.client_secret, self.region
|
|
31
|
+
)
|