blizzardapi2 3.0.4__tar.gz → 4.0.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.
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/.gitignore +7 -1
- {blizzardapi2-3.0.4/blizzardapi2.egg-info → blizzardapi2-4.0.0}/PKG-INFO +2 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/api.py +66 -36
- blizzardapi2-4.0.0/blizzardapi2/battlenet/battlenet_api.py +19 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/battlenet/battlenet_oauth_api.py +6 -24
- blizzardapi2-4.0.0/blizzardapi2/blizzard_api.py +42 -0
- blizzardapi2-4.0.0/blizzardapi2/diablo3/diablo3_api.py +31 -0
- blizzardapi2-4.0.0/blizzardapi2/diablo3/diablo3_community_api.py +315 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/diablo3/diablo3_game_data_api.py +20 -24
- blizzardapi2-4.0.0/blizzardapi2/endpoint.py +81 -0
- blizzardapi2-4.0.0/blizzardapi2/hearthstone/hearthstone_api.py +38 -0
- blizzardapi2-4.0.0/blizzardapi2/hearthstone/hearthstone_game_data_api.py +170 -0
- blizzardapi2-4.0.0/blizzardapi2/starcraft2/starcraft2_api.py +29 -0
- blizzardapi2-4.0.0/blizzardapi2/starcraft2/starcraft2_community_api.py +209 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/starcraft2/starcraft2_game_data_api.py +10 -13
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/types.py +7 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/wow/wow_api.py +10 -14
- blizzardapi2-4.0.0/blizzardapi2/wow/wow_game_data_api.py +3181 -0
- blizzardapi2-4.0.0/blizzardapi2/wow/wow_profile_api.py +1098 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0/blizzardapi2.egg-info}/PKG-INFO +2 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2.egg-info/SOURCES.txt +1 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2.egg-info/requires.txt +1 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/package.json +1 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/pyproject.toml +2 -1
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/tests/test_base_api.py +165 -3
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/tests/test_battlenet.py +23 -8
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/tests/test_diablo3.py +7 -7
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/tests/test_hearthstone.py +12 -15
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/tests/test_starcraft2.py +2 -7
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/tests/test_wow.py +90 -7
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/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.0}/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/.github/dependabot.yml +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/.github/workflows/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/.github/workflows/black-check.yml +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/.github/workflows/python-package.yml +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/.pre-commit-config.yaml +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/.release-it.json +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/CLAUDE.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/CODE_OF_CONDUCT.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/CONTRIBUTING.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/LICENSE +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/SECURITY.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/battlenet/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/diablo3/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/hearthstone/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/starcraft2/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2/wow/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2.egg-info/dependency_links.txt +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/blizzardapi2.egg-info/top_level.txt +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/docs/battlenet/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/docs/diablo3/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/docs/hearthstone/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/docs/pull_request_template.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/docs/starcraft2/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/docs/wow/README.md +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/setup.cfg +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/tests/__init__.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/tests/conftest.py +0 -0
- {blizzardapi2-3.0.4 → blizzardapi2-4.0.0}/tests/test_types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: blizzardapi2
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.0.0
|
|
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
|
+
)
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
|
|
3
|
+
from ..api import LocaleApi
|
|
4
|
+
from ..types import OptionalLocale, OptionalRegion
|
|
5
|
+
|
|
6
|
+
"""diablo3_community_api.py file."""
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Diablo3CommunityApi(LocaleApi):
|
|
10
|
+
"""All Diablo 3 Community API methods.
|
|
11
|
+
|
|
12
|
+
Attributes:
|
|
13
|
+
client_id (str): A string client ID supplied by Blizzard.
|
|
14
|
+
client_secret (str): A string client secret supplied by Blizzard.
|
|
15
|
+
region (Region, optional): A default region to use for requests.
|
|
16
|
+
locale (Locale, optional): A default locale to use for requests.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def get_act_index(
|
|
20
|
+
self, *, region: OptionalRegion = None, locale: OptionalLocale = None
|
|
21
|
+
) -> dict[str, Any]:
|
|
22
|
+
"""
|
|
23
|
+
Return an index of acts.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
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.
|
|
27
|
+
locale (Locale, optional): 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.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
Dict[str, Any]: A dictionary containing the index of acts.
|
|
31
|
+
"""
|
|
32
|
+
resource = "/d3/data/act"
|
|
33
|
+
return super().get_resource(resource, region, locale=locale)
|
|
34
|
+
|
|
35
|
+
def get_act(
|
|
36
|
+
self,
|
|
37
|
+
act_id: int,
|
|
38
|
+
*,
|
|
39
|
+
region: OptionalRegion = None,
|
|
40
|
+
locale: OptionalLocale = None,
|
|
41
|
+
) -> dict[str, Any]:
|
|
42
|
+
"""
|
|
43
|
+
Return a single act by ID.
|
|
44
|
+
|
|
45
|
+
Args:
|
|
46
|
+
act_id (int): The ID of the act to retrieve.
|
|
47
|
+
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.
|
|
48
|
+
locale (Locale, optional): 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.
|
|
49
|
+
|
|
50
|
+
Returns:
|
|
51
|
+
Dict[str, Any]: A dictionary containing the act details.
|
|
52
|
+
"""
|
|
53
|
+
resource = f"/d3/data/act/{act_id}"
|
|
54
|
+
return super().get_resource(resource, region, locale=locale)
|
|
55
|
+
|
|
56
|
+
def get_artisan(
|
|
57
|
+
self,
|
|
58
|
+
artisan_slug: str,
|
|
59
|
+
*,
|
|
60
|
+
region: OptionalRegion = None,
|
|
61
|
+
locale: OptionalLocale = None,
|
|
62
|
+
) -> dict[str, Any]:
|
|
63
|
+
"""
|
|
64
|
+
Return a single artisan by slug.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
artisan_slug (str): The slug of the artisan to retrieve.
|
|
68
|
+
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.
|
|
69
|
+
locale (Locale, optional): 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.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
Dict[str, Any]: A dictionary containing the artisan details.
|
|
73
|
+
"""
|
|
74
|
+
resource = f"/d3/data/artisan/{artisan_slug}"
|
|
75
|
+
return super().get_resource(resource, region, locale=locale)
|
|
76
|
+
|
|
77
|
+
def get_recipe(
|
|
78
|
+
self,
|
|
79
|
+
artisan_slug: str,
|
|
80
|
+
recipe_slug: str,
|
|
81
|
+
*,
|
|
82
|
+
region: OptionalRegion = None,
|
|
83
|
+
locale: OptionalLocale = None,
|
|
84
|
+
) -> dict[str, Any]:
|
|
85
|
+
"""
|
|
86
|
+
Return a single recipe by slug for the specified artisan.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
artisan_slug (str): The slug of the artisan.
|
|
90
|
+
recipe_slug (str): The slug of the recipe to retrieve.
|
|
91
|
+
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.
|
|
92
|
+
locale (Locale, optional): 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.
|
|
93
|
+
|
|
94
|
+
Returns:
|
|
95
|
+
Dict[str, Any]: A dictionary containing the recipe details.
|
|
96
|
+
"""
|
|
97
|
+
resource = f"/d3/data/artisan/{artisan_slug}/recipe/{recipe_slug}"
|
|
98
|
+
return super().get_resource(resource, region, locale=locale)
|
|
99
|
+
|
|
100
|
+
def get_follower(
|
|
101
|
+
self,
|
|
102
|
+
follower_slug: str,
|
|
103
|
+
*,
|
|
104
|
+
region: OptionalRegion = None,
|
|
105
|
+
locale: OptionalLocale = None,
|
|
106
|
+
) -> dict[str, Any]:
|
|
107
|
+
"""
|
|
108
|
+
Return a single follower by slug.
|
|
109
|
+
|
|
110
|
+
Args:
|
|
111
|
+
follower_slug (str): The slug of the follower to retrieve.
|
|
112
|
+
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.
|
|
113
|
+
locale (Locale, optional): 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.
|
|
114
|
+
|
|
115
|
+
Returns:
|
|
116
|
+
Dict[str, Any]: A dictionary containing the follower details.
|
|
117
|
+
"""
|
|
118
|
+
resource = f"/d3/data/follower/{follower_slug}"
|
|
119
|
+
return super().get_resource(resource, region, locale=locale)
|
|
120
|
+
|
|
121
|
+
def get_character_class(
|
|
122
|
+
self,
|
|
123
|
+
class_slug: str,
|
|
124
|
+
*,
|
|
125
|
+
region: OptionalRegion = None,
|
|
126
|
+
locale: OptionalLocale = None,
|
|
127
|
+
) -> dict[str, Any]:
|
|
128
|
+
"""
|
|
129
|
+
Return a single character class by slug.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
class_slug (str): The slug of the character class to retrieve.
|
|
133
|
+
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.
|
|
134
|
+
locale (Locale, optional): 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.
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
Dict[str, Any]: A dictionary containing the character class details.
|
|
138
|
+
"""
|
|
139
|
+
resource = f"/d3/data/hero/{class_slug}"
|
|
140
|
+
return super().get_resource(resource, region, locale=locale)
|
|
141
|
+
|
|
142
|
+
def get_api_skill(
|
|
143
|
+
self,
|
|
144
|
+
class_slug: str,
|
|
145
|
+
skill_slug: str,
|
|
146
|
+
*,
|
|
147
|
+
region: OptionalRegion = None,
|
|
148
|
+
locale: OptionalLocale = None,
|
|
149
|
+
) -> dict[str, Any]:
|
|
150
|
+
"""
|
|
151
|
+
Return a single skill by slug for a specific character class.
|
|
152
|
+
|
|
153
|
+
Args:
|
|
154
|
+
class_slug (str): The slug of the character class.
|
|
155
|
+
skill_slug (str): The slug of the skill to retrieve.
|
|
156
|
+
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.
|
|
157
|
+
locale (Locale, optional): 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.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
Dict[str, Any]: A dictionary containing the skill details.
|
|
161
|
+
"""
|
|
162
|
+
resource = f"/d3/data/hero/{class_slug}/skill/{skill_slug}"
|
|
163
|
+
return super().get_resource(resource, region, locale=locale)
|
|
164
|
+
|
|
165
|
+
def get_item_type_index(
|
|
166
|
+
self,
|
|
167
|
+
*,
|
|
168
|
+
region: OptionalRegion = None,
|
|
169
|
+
locale: OptionalLocale = None,
|
|
170
|
+
) -> dict[str, Any]:
|
|
171
|
+
"""
|
|
172
|
+
Return an index of item types.
|
|
173
|
+
|
|
174
|
+
Args:
|
|
175
|
+
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.
|
|
176
|
+
locale (Locale, optional): 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.
|
|
177
|
+
|
|
178
|
+
Returns:
|
|
179
|
+
Dict[str, Any]: A dictionary containing the index of item types.
|
|
180
|
+
"""
|
|
181
|
+
resource = "/d3/data/item-type"
|
|
182
|
+
return super().get_resource(resource, region, locale=locale)
|
|
183
|
+
|
|
184
|
+
def get_item_type(
|
|
185
|
+
self,
|
|
186
|
+
item_type_slug: str,
|
|
187
|
+
*,
|
|
188
|
+
region: OptionalRegion = None,
|
|
189
|
+
locale: OptionalLocale = None,
|
|
190
|
+
) -> dict[str, Any]:
|
|
191
|
+
"""
|
|
192
|
+
Return a single item type by slug.
|
|
193
|
+
|
|
194
|
+
Args:
|
|
195
|
+
item_type_slug (str): The slug of the item type to retrieve.
|
|
196
|
+
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.
|
|
197
|
+
locale (Locale, optional): 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.
|
|
198
|
+
|
|
199
|
+
Returns:
|
|
200
|
+
Dict[str, Any]: A dictionary containing the item type details.
|
|
201
|
+
"""
|
|
202
|
+
resource = f"/d3/data/item-type/{item_type_slug}"
|
|
203
|
+
return super().get_resource(resource, region, locale=locale)
|
|
204
|
+
|
|
205
|
+
def get_item(
|
|
206
|
+
self,
|
|
207
|
+
item_slug_id: str,
|
|
208
|
+
*,
|
|
209
|
+
region: OptionalRegion = None,
|
|
210
|
+
locale: OptionalLocale = None,
|
|
211
|
+
) -> dict[str, Any]:
|
|
212
|
+
"""
|
|
213
|
+
Return a single item by item slug and ID.
|
|
214
|
+
|
|
215
|
+
Args:
|
|
216
|
+
item_slug_id (str): The slug and ID of the item to retrieve.
|
|
217
|
+
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.
|
|
218
|
+
locale (Locale, optional): 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.
|
|
219
|
+
|
|
220
|
+
Returns:
|
|
221
|
+
Dict[str, Any]: A dictionary containing the item details.
|
|
222
|
+
"""
|
|
223
|
+
resource = f"/d3/data/item/{item_slug_id}"
|
|
224
|
+
return super().get_resource(resource, region, locale=locale)
|
|
225
|
+
|
|
226
|
+
def get_api_account(
|
|
227
|
+
self,
|
|
228
|
+
account_id: str,
|
|
229
|
+
*,
|
|
230
|
+
region: OptionalRegion = None,
|
|
231
|
+
locale: OptionalLocale = None,
|
|
232
|
+
) -> dict[str, Any]:
|
|
233
|
+
"""
|
|
234
|
+
Return the specified account profile.
|
|
235
|
+
|
|
236
|
+
Args:
|
|
237
|
+
account_id (str): The ID of the account to retrieve.
|
|
238
|
+
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.
|
|
239
|
+
locale (Locale, optional): 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.
|
|
240
|
+
|
|
241
|
+
Returns:
|
|
242
|
+
Dict[str, Any]: A dictionary containing the account profile details.
|
|
243
|
+
"""
|
|
244
|
+
resource = f"/d3/profile/{account_id}/"
|
|
245
|
+
return super().get_resource(resource, region, locale=locale)
|
|
246
|
+
|
|
247
|
+
def get_api_hero(
|
|
248
|
+
self,
|
|
249
|
+
account_id: str,
|
|
250
|
+
hero_id: int,
|
|
251
|
+
*,
|
|
252
|
+
region: OptionalRegion = None,
|
|
253
|
+
locale: OptionalLocale = None,
|
|
254
|
+
) -> dict[str, Any]:
|
|
255
|
+
"""
|
|
256
|
+
Return a single hero.
|
|
257
|
+
|
|
258
|
+
Args:
|
|
259
|
+
account_id (str): The ID of the account.
|
|
260
|
+
hero_id (int): The ID of the hero to retrieve.
|
|
261
|
+
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.
|
|
262
|
+
locale (Locale, optional): 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.
|
|
263
|
+
|
|
264
|
+
Returns:
|
|
265
|
+
Dict[str, Any]: A dictionary containing the hero details.
|
|
266
|
+
"""
|
|
267
|
+
resource = f"/d3/profile/{account_id}/hero/{hero_id}"
|
|
268
|
+
return super().get_resource(resource, region, locale=locale)
|
|
269
|
+
|
|
270
|
+
def get_api_detailed_hero_items(
|
|
271
|
+
self,
|
|
272
|
+
account_id: str,
|
|
273
|
+
hero_id: int,
|
|
274
|
+
*,
|
|
275
|
+
region: OptionalRegion = None,
|
|
276
|
+
locale: OptionalLocale = None,
|
|
277
|
+
) -> dict[str, Any]:
|
|
278
|
+
"""
|
|
279
|
+
Return a list of items for the specified hero.
|
|
280
|
+
|
|
281
|
+
Args:
|
|
282
|
+
account_id (str): The ID of the account.
|
|
283
|
+
hero_id (int): The ID of the hero.
|
|
284
|
+
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.
|
|
285
|
+
locale (Locale, optional): 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.
|
|
286
|
+
|
|
287
|
+
Returns:
|
|
288
|
+
Dict[str, Any]: A dictionary containing the list of items for the hero.
|
|
289
|
+
"""
|
|
290
|
+
resource = f"/d3/profile/{account_id}/hero/{hero_id}/items"
|
|
291
|
+
return super().get_resource(resource, region, locale=locale)
|
|
292
|
+
|
|
293
|
+
def get_api_detailed_follower_items(
|
|
294
|
+
self,
|
|
295
|
+
account_id: str,
|
|
296
|
+
hero_id: int,
|
|
297
|
+
*,
|
|
298
|
+
region: OptionalRegion = None,
|
|
299
|
+
locale: OptionalLocale = None,
|
|
300
|
+
) -> dict[str, Any]:
|
|
301
|
+
"""
|
|
302
|
+
Return the equipped follower items for a given hero.
|
|
303
|
+
|
|
304
|
+
Args:
|
|
305
|
+
account_id (str): The ID of the account.
|
|
306
|
+
hero_id (int): The ID of the hero.
|
|
307
|
+
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.
|
|
308
|
+
locale (Locale, optional): 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.
|
|
309
|
+
|
|
310
|
+
Returns:
|
|
311
|
+
Dict[str, Any]: A dictionary containing the follower items
|
|
312
|
+
equipped on the specified hero.
|
|
313
|
+
"""
|
|
314
|
+
resource = f"/d3/profile/{account_id}/hero/{hero_id}/follower-items"
|
|
315
|
+
return super().get_resource(resource, region, locale=locale)
|