blizzardapi2 0.1.3__tar.gz → 0.1.4__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-0.1.3 → blizzardapi2-0.1.4}/PKG-INFO +4 -4
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/README.md +1 -1
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/__init__.py +1 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/api.py +34 -10
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/battlenet/battlenet_api.py +1 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/battlenet/battlenet_oauth_api.py +1 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/blizzard_api.py +1 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/diablo3/diablo3_community_api.py +30 -10
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/diablo3/diablo3_game_data_api.py +6 -2
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/hearthstone/hearthstone_game_data_api.py +15 -6
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/starcraft2/starcraft2_api.py +6 -2
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/starcraft2/starcraft2_community_api.py +38 -10
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/starcraft2/starcraft2_game_data_api.py +7 -4
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/wow/wow_game_data_api.py +194 -155
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/wow/wow_profile_api.py +73 -30
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/pyproject.toml +2 -2
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/LICENSE +0 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/battlenet/__init__.py +0 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/diablo3/__init__.py +0 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/diablo3/diablo3_api.py +0 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/hearthstone/__init__.py +0 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/hearthstone/hearthstone_api.py +0 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/starcraft2/__init__.py +0 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/wow/__init__.py +0 -0
- {blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/wow/wow_api.py +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: blizzardapi2
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
4
4
|
Summary: A Python wrapper for Blizzard API
|
|
5
5
|
License: MIT
|
|
6
|
-
Author:
|
|
7
|
-
Author-email:
|
|
6
|
+
Author: lostcol0ny
|
|
7
|
+
Author-email: c098os0k@4wrd.cc
|
|
8
8
|
Requires-Python: >=3.11,<4.0
|
|
9
9
|
Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -17,7 +17,7 @@ Requires-Dist: requests (>=2.32.3,<3.0.0)
|
|
|
17
17
|
Description-Content-Type: text/markdown
|
|
18
18
|
|
|
19
19
|
# blizzardapi2
|
|
20
|
-
[[](https://github.com/lostcol0ny/python-blizzardapi2/actions/workflows/python-package.yml)[](https://github.com/lostcol0ny/blizzardapi2/actions/workflows/dependabot/dependabot-updates)[](https://github.com/lostcol0ny/python-blizzardapi2/actions/workflows/github-code-scanning/codeql)[](https://github.com/psf/black)
|
|
21
21
|
|
|
22
22
|
blizzardapi2 is a client library for Blizzard's APIs. It's a fork of [the original library](https://github.com/trevorphillipscoding/python-blizzardapi/).
|
|
23
23
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# blizzardapi2
|
|
2
|
-
[[](https://github.com/lostcol0ny/python-blizzardapi2/actions/workflows/python-package.yml)[](https://github.com/lostcol0ny/blizzardapi2/actions/workflows/dependabot/dependabot-updates)[](https://github.com/lostcol0ny/python-blizzardapi2/actions/workflows/github-code-scanning/codeql)[](https://github.com/psf/black)
|
|
3
3
|
|
|
4
4
|
blizzardapi2 is a client library for Blizzard's APIs. It's a fork of [the original library](https://github.com/trevorphillipscoding/python-blizzardapi/).
|
|
5
5
|
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
"""api.py file."""
|
|
2
|
+
|
|
2
3
|
from typing import Dict, Any
|
|
3
4
|
import requests
|
|
4
5
|
|
|
6
|
+
import time
|
|
7
|
+
|
|
5
8
|
|
|
6
9
|
class Api:
|
|
7
10
|
"""Base API class.
|
|
@@ -22,6 +25,7 @@ class Api:
|
|
|
22
25
|
self._client_id = client_id
|
|
23
26
|
self._client_secret = client_secret
|
|
24
27
|
self._access_token = None
|
|
28
|
+
self._token_expiration = 0
|
|
25
29
|
|
|
26
30
|
self._api_url = "https://{0}.api.blizzard.com{1}"
|
|
27
31
|
self._api_url_cn = "https://gateway.battlenet.com.cn{0}"
|
|
@@ -31,6 +35,10 @@ class Api:
|
|
|
31
35
|
|
|
32
36
|
self._session = requests.Session()
|
|
33
37
|
|
|
38
|
+
def _is_token_expired(self) -> bool:
|
|
39
|
+
"""Check if the token has expired."""
|
|
40
|
+
return time() >= self._access_token["expires_at"]
|
|
41
|
+
|
|
34
42
|
def _get_client_token(self, region: str) -> Dict[str, Any]:
|
|
35
43
|
"""Fetch an access token based on client id and client secret credentials.
|
|
36
44
|
|
|
@@ -47,23 +55,35 @@ class Api:
|
|
|
47
55
|
auth=(self._client_id, self._client_secret),
|
|
48
56
|
)
|
|
49
57
|
|
|
50
|
-
|
|
58
|
+
json_response = self.response_handler(response)
|
|
59
|
+
self._access_token = json_response["access_token"]
|
|
60
|
+
self._token_expiration = time() + json_response["expires_in"] - 300
|
|
61
|
+
|
|
62
|
+
def _ensure_valid_token (self, region: str) -> None:
|
|
63
|
+
"""Ensure that the token is valid."""
|
|
64
|
+
if self._access_token is None or self._is_token_expired():
|
|
65
|
+
self._get_client_token(region)
|
|
51
66
|
|
|
52
67
|
def _response_handler(self, response: requests.Response) -> Dict[str, Any]:
|
|
53
68
|
"""Handle the response."""
|
|
54
69
|
return response.json()
|
|
55
70
|
|
|
56
|
-
def _request_handler(
|
|
71
|
+
def _request_handler(
|
|
72
|
+
self, url: str, region: str, query_params: Dict[str, Any]
|
|
73
|
+
) -> Dict[str, Any]:
|
|
57
74
|
"""Handle the request."""
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
self._access_token = json["access_token"]
|
|
61
|
-
|
|
75
|
+
self._ensure_valid_token(region)
|
|
76
|
+
|
|
62
77
|
if query_params.get("access_token") is None:
|
|
63
78
|
query_params["access_token"] = self._access_token
|
|
64
|
-
|
|
79
|
+
|
|
65
80
|
response = self._session.get(url, params=query_params)
|
|
66
|
-
|
|
81
|
+
|
|
82
|
+
if response.status_code == 401:
|
|
83
|
+
self._get_client_token(region)
|
|
84
|
+
query_params["access_token"] = self._access_token
|
|
85
|
+
response = self._session.get(url, params=query_params)
|
|
86
|
+
|
|
67
87
|
return self._response_handler(response)
|
|
68
88
|
|
|
69
89
|
def _format_api_url(self, resource: str, region: str) -> str:
|
|
@@ -75,7 +95,9 @@ class Api:
|
|
|
75
95
|
|
|
76
96
|
return url
|
|
77
97
|
|
|
78
|
-
def get_resource(
|
|
98
|
+
def get_resource(
|
|
99
|
+
self, resource: str, region: str, query_params={}
|
|
100
|
+
) -> Dict[str, Any]:
|
|
79
101
|
"""Direction handler for when fetching resources."""
|
|
80
102
|
url = self._format_api_url(resource, region)
|
|
81
103
|
return self._request_handler(url, region, query_params)
|
|
@@ -89,7 +111,9 @@ class Api:
|
|
|
89
111
|
|
|
90
112
|
return url
|
|
91
113
|
|
|
92
|
-
def get_oauth_resource(
|
|
114
|
+
def get_oauth_resource(
|
|
115
|
+
self, resource: str, region: str, query_params={}
|
|
116
|
+
) -> Dict[str, Any]:
|
|
93
117
|
"""Direction handler for when fetching oauth resources."""
|
|
94
118
|
url = self._format_oauth_url(resource, region)
|
|
95
119
|
return self._request_handler(url, region, query_params)
|
|
@@ -32,13 +32,17 @@ class Diablo3CommunityApi(Api):
|
|
|
32
32
|
|
|
33
33
|
# D3 Artisan and Recipe API
|
|
34
34
|
|
|
35
|
-
def get_artisan(
|
|
35
|
+
def get_artisan(
|
|
36
|
+
self, region: str, locale: str, artisan_slug: str
|
|
37
|
+
) -> Dict[str, Any]:
|
|
36
38
|
"""Return a single artisan by slug."""
|
|
37
39
|
resource = f"/d3/data/artisan/{artisan_slug}"
|
|
38
40
|
query_params = {"locale": locale}
|
|
39
41
|
return super().get_resource(resource, region, query_params)
|
|
40
42
|
|
|
41
|
-
def get_recipe(
|
|
43
|
+
def get_recipe(
|
|
44
|
+
self, region: str, locale: str, artisan_slug: str, recipe_slug: str
|
|
45
|
+
) -> Dict[str, Any]:
|
|
42
46
|
"""Return a single recipe by slug for the specified artisan."""
|
|
43
47
|
resource = f"/d3/data/artisan/{artisan_slug}/recipe/{recipe_slug}"
|
|
44
48
|
query_params = {"locale": locale}
|
|
@@ -46,7 +50,9 @@ class Diablo3CommunityApi(Api):
|
|
|
46
50
|
|
|
47
51
|
# D3 Follower API
|
|
48
52
|
|
|
49
|
-
def get_follower(
|
|
53
|
+
def get_follower(
|
|
54
|
+
self, region: str, locale: str, follower_slug: str
|
|
55
|
+
) -> Dict[str, Any]:
|
|
50
56
|
"""Return a single follower by slug."""
|
|
51
57
|
resource = f"/d3/data/follower/{follower_slug}"
|
|
52
58
|
query_params = {"locale": locale}
|
|
@@ -54,13 +60,17 @@ class Diablo3CommunityApi(Api):
|
|
|
54
60
|
|
|
55
61
|
# D3 Character Class and Skill API
|
|
56
62
|
|
|
57
|
-
def get_character_class(
|
|
63
|
+
def get_character_class(
|
|
64
|
+
self, region: str, locale: str, class_slug: str
|
|
65
|
+
) -> Dict[str, Any]:
|
|
58
66
|
"""Return a single character class by slug."""
|
|
59
67
|
resource = f"/d3/data/hero/{class_slug}"
|
|
60
68
|
query_params = {"locale": locale}
|
|
61
69
|
return super().get_resource(resource, region, query_params)
|
|
62
70
|
|
|
63
|
-
def get_api_skill(
|
|
71
|
+
def get_api_skill(
|
|
72
|
+
self, region: str, locale: str, class_slug: str, skill_slug: str
|
|
73
|
+
) -> Dict[str, Any]:
|
|
64
74
|
"""Return a single skill by slug for a specific character class."""
|
|
65
75
|
resource = f"/d3/data/hero/{class_slug}/skill/{skill_slug}"
|
|
66
76
|
query_params = {"locale": locale}
|
|
@@ -74,7 +84,9 @@ class Diablo3CommunityApi(Api):
|
|
|
74
84
|
query_params = {"locale": locale}
|
|
75
85
|
return super().get_resource(resource, region, query_params)
|
|
76
86
|
|
|
77
|
-
def get_item_type(
|
|
87
|
+
def get_item_type(
|
|
88
|
+
self, region: str, locale: str, item_type_slug: str
|
|
89
|
+
) -> Dict[str, Any]:
|
|
78
90
|
"""Return a single item type by slug."""
|
|
79
91
|
resource = f"/d3/data/item-type/{item_type_slug}"
|
|
80
92
|
query_params = {"locale": locale}
|
|
@@ -90,25 +102,33 @@ class Diablo3CommunityApi(Api):
|
|
|
90
102
|
|
|
91
103
|
# D3 Profile API
|
|
92
104
|
|
|
93
|
-
def get_api_account(
|
|
105
|
+
def get_api_account(
|
|
106
|
+
self, region: str, locale: str, account_id: str
|
|
107
|
+
) -> Dict[str, Any]:
|
|
94
108
|
"""Return the specified account profile."""
|
|
95
109
|
resource = f"/d3/profile/{account_id}/"
|
|
96
110
|
query_params = {"locale": locale}
|
|
97
111
|
return super().get_resource(resource, region, query_params)
|
|
98
112
|
|
|
99
|
-
def get_api_hero(
|
|
113
|
+
def get_api_hero(
|
|
114
|
+
self, region: str, locale: str, account_id: str, hero_id: int
|
|
115
|
+
) -> Dict[str, Any]:
|
|
100
116
|
"""Return a single hero."""
|
|
101
117
|
resource = f"/d3/profile/{account_id}/hero/{hero_id}"
|
|
102
118
|
query_params = {"locale": locale}
|
|
103
119
|
return super().get_resource(resource, region, query_params)
|
|
104
120
|
|
|
105
|
-
def get_api_detailed_hero_items(
|
|
121
|
+
def get_api_detailed_hero_items(
|
|
122
|
+
self, region: str, locale: str, account_id: str, hero_id: int
|
|
123
|
+
) -> Dict[str, Any]:
|
|
106
124
|
"""Return a list of items for the specified hero."""
|
|
107
125
|
resource = f"/d3/profile/{account_id}/hero/{hero_id}/items"
|
|
108
126
|
query_params = {"locale": locale}
|
|
109
127
|
return super().get_resource(resource, region, query_params)
|
|
110
128
|
|
|
111
|
-
def get_api_detailed_follower_items(
|
|
129
|
+
def get_api_detailed_follower_items(
|
|
130
|
+
self, region: str, locale: str, account_id: str, hero_id: int
|
|
131
|
+
) -> Dict[str, Any]:
|
|
112
132
|
"""Return a single item by item slug and ID."""
|
|
113
133
|
resource = f"/d3/profile/{account_id}/hero/{hero_id}/follower-items"
|
|
114
134
|
query_params = {"locale": locale}
|
|
@@ -28,7 +28,9 @@ class Diablo3GameDataApi(Api):
|
|
|
28
28
|
resource = f"/data/d3/season/{season_id}"
|
|
29
29
|
return super().get_resource(resource, region)
|
|
30
30
|
|
|
31
|
-
def get_season_leaderboard(
|
|
31
|
+
def get_season_leaderboard(
|
|
32
|
+
self, region: str, season_id: int, leaderboard_id: int
|
|
33
|
+
) -> Dict:
|
|
32
34
|
"""Return the specified leaderboard for the specified season."""
|
|
33
35
|
resource = f"/data/d3/season/{season_id}/leaderboard/{leaderboard_id}"
|
|
34
36
|
return super().get_resource(resource, region)
|
|
@@ -43,7 +45,9 @@ class Diablo3GameDataApi(Api):
|
|
|
43
45
|
resource = f"/data/d3/era/{era_id}"
|
|
44
46
|
return super().get_resource(resource, region)
|
|
45
47
|
|
|
46
|
-
def get_era_leaderboard(
|
|
48
|
+
def get_era_leaderboard(
|
|
49
|
+
self, region: str, era_id: int, leaderboard_id: int
|
|
50
|
+
) -> Dict:
|
|
47
51
|
"""Return the specified leaderboard for the specified era."""
|
|
48
52
|
resource = f"/data/d3/era/{era_id}/leaderboard/{leaderboard_id}"
|
|
49
53
|
return super().get_resource(resource, region)
|
{blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/hearthstone/hearthstone_game_data_api.py
RENAMED
|
@@ -4,7 +4,6 @@ from ..api import Api
|
|
|
4
4
|
"""hearthstone_game_data_api.py file."""
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
class HearthstoneGameDataApi(Api):
|
|
9
8
|
"""All Hearthstone Game Data API methods.
|
|
10
9
|
|
|
@@ -19,13 +18,17 @@ class HearthstoneGameDataApi(Api):
|
|
|
19
18
|
|
|
20
19
|
# Cards
|
|
21
20
|
|
|
22
|
-
def search_cards(
|
|
21
|
+
def search_cards(
|
|
22
|
+
self, region: str, locale: str, **query_params: Any
|
|
23
|
+
) -> Dict[str, Any]:
|
|
23
24
|
"""Return an up-to-date list of all cards matching the search criteria."""
|
|
24
25
|
resource = "/hearthstone/cards"
|
|
25
26
|
query_params.update({"locale": locale})
|
|
26
27
|
return super().get_resource(resource, region, query_params)
|
|
27
28
|
|
|
28
|
-
def get_card(
|
|
29
|
+
def get_card(
|
|
30
|
+
self, region: str, locale: str, id_or_slug: str, game_mode: str = "constructed"
|
|
31
|
+
) -> Dict[str, Any]:
|
|
29
32
|
"""Return the card with an ID or slug that matches the one you specify."""
|
|
30
33
|
resource = f"/hearthstone/cards/{id_or_slug}"
|
|
31
34
|
query_params = {"locale": locale, "game_mode": game_mode}
|
|
@@ -33,13 +36,17 @@ class HearthstoneGameDataApi(Api):
|
|
|
33
36
|
|
|
34
37
|
# Card Backs
|
|
35
38
|
|
|
36
|
-
def search_card_backs(
|
|
39
|
+
def search_card_backs(
|
|
40
|
+
self, region: str, locale: str, **query_params: Any
|
|
41
|
+
) -> Dict[str, Any]:
|
|
37
42
|
"""Return an up-to-date list of all card backs matching the search criteria."""
|
|
38
43
|
resource = "/hearthstone/cardbacks"
|
|
39
44
|
query_params.update({"locale": locale})
|
|
40
45
|
return super().get_resource(resource, region, query_params)
|
|
41
46
|
|
|
42
|
-
def get_card_back(
|
|
47
|
+
def get_card_back(
|
|
48
|
+
self, region: str, locale: str, id_or_slug: str
|
|
49
|
+
) -> Dict[str, Any]:
|
|
43
50
|
"""Return a specific card back by using card back ID or slug."""
|
|
44
51
|
resource = f"/hearthstone/cardbacks/{id_or_slug}"
|
|
45
52
|
query_params = {"locale": locale}
|
|
@@ -61,7 +68,9 @@ class HearthstoneGameDataApi(Api):
|
|
|
61
68
|
query_params = {"locale": locale}
|
|
62
69
|
return super().get_resource(resource, region, query_params)
|
|
63
70
|
|
|
64
|
-
def get_metadata_type(
|
|
71
|
+
def get_metadata_type(
|
|
72
|
+
self, region: str, locale: str, type_id: str
|
|
73
|
+
) -> Dict[str, Any]:
|
|
65
74
|
"""Return information about just one type of metadata."""
|
|
66
75
|
resource = f"/hearthstone/metadata/{type_id}"
|
|
67
76
|
query_params = {"locale": locale}
|
|
@@ -14,5 +14,9 @@ class Starcraft2Api:
|
|
|
14
14
|
|
|
15
15
|
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
16
16
|
"""Init Starcraft2."""
|
|
17
|
-
self.community: Starcraft2CommunityApi = Starcraft2CommunityApi(
|
|
18
|
-
|
|
17
|
+
self.community: Starcraft2CommunityApi = Starcraft2CommunityApi(
|
|
18
|
+
client_id, client_secret
|
|
19
|
+
)
|
|
20
|
+
self.game_data: Starcraft2GameDataApi = Starcraft2GameDataApi(
|
|
21
|
+
client_id, client_secret
|
|
22
|
+
)
|
{blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/starcraft2/starcraft2_community_api.py
RENAMED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
"""starcraft2_community_api.py file."""
|
|
2
|
+
|
|
2
3
|
from typing import Dict, Any
|
|
3
4
|
from ..api import Api
|
|
4
5
|
|
|
6
|
+
|
|
5
7
|
class Starcraft2CommunityApi(Api):
|
|
6
8
|
"""All Starcraft 2 Community API methods.
|
|
7
9
|
Attributes:
|
|
8
10
|
client_id: A string client id supplied by Blizzard.
|
|
9
11
|
client_secret: A string client secret supplied by Blizzard.
|
|
10
12
|
"""
|
|
13
|
+
|
|
11
14
|
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
12
15
|
"""Init Starcraft2CommunityApi."""
|
|
13
16
|
super().__init__(client_id, client_secret)
|
|
@@ -19,33 +22,58 @@ class Starcraft2CommunityApi(Api):
|
|
|
19
22
|
query_params = {"locale": locale}
|
|
20
23
|
return super().get_resource(resource, region, query_params)
|
|
21
24
|
|
|
22
|
-
def get_metadata(
|
|
25
|
+
def get_metadata(
|
|
26
|
+
self, region: str, locale: str, region_id: int, realm_id: int, profile_id: int
|
|
27
|
+
) -> Dict[str, Any]:
|
|
23
28
|
"""Returns metadata for an individual's profile."""
|
|
24
29
|
resource = f"/sc2/metadata/profile/{region_id}/{realm_id}/{profile_id}"
|
|
25
30
|
query_params = {"locale": locale}
|
|
26
31
|
return super().get_resource(resource, region, query_params)
|
|
27
32
|
|
|
28
|
-
def get_profile(
|
|
33
|
+
def get_profile(
|
|
34
|
+
self,
|
|
35
|
+
region: str,
|
|
36
|
+
locale: str,
|
|
37
|
+
region_id: int,
|
|
38
|
+
realm_id: int,
|
|
39
|
+
profile_id: int,
|
|
40
|
+
**query_params: Any,
|
|
41
|
+
) -> Dict[str, Any]:
|
|
29
42
|
"""Returns data about an individual SC2 profile."""
|
|
30
43
|
resource = f"/sc2/profile/{region_id}/{realm_id}/{profile_id}"
|
|
31
44
|
query_params["locale"] = locale
|
|
32
45
|
return super().get_resource(resource, region, query_params)
|
|
33
46
|
|
|
34
|
-
def get_ladder_summary(
|
|
47
|
+
def get_ladder_summary(
|
|
48
|
+
self, region: str, locale: str, region_id: int, realm_id: int, profile_id: int
|
|
49
|
+
) -> Dict[str, Any]:
|
|
35
50
|
"""Returns a ladder summary for an individual SC2 profile."""
|
|
36
51
|
resource = f"/sc2/profile/{region_id}/{realm_id}/{profile_id}/ladder/summary"
|
|
37
52
|
query_params = {"locale": locale}
|
|
38
53
|
return super().get_resource(resource, region, query_params)
|
|
39
54
|
|
|
40
|
-
def get_ladder(
|
|
55
|
+
def get_ladder(
|
|
56
|
+
self,
|
|
57
|
+
region: str,
|
|
58
|
+
locale: str,
|
|
59
|
+
region_id: int,
|
|
60
|
+
realm_id: int,
|
|
61
|
+
profile_id: int,
|
|
62
|
+
ladder_id: int,
|
|
63
|
+
**query_params: Any,
|
|
64
|
+
) -> Dict[str, Any]:
|
|
41
65
|
"""Returns data about an individual profile's ladder."""
|
|
42
|
-
resource =
|
|
66
|
+
resource = (
|
|
67
|
+
f"/sc2/profile/{region_id}/{realm_id}/{profile_id}/ladder/{ladder_id}"
|
|
68
|
+
)
|
|
43
69
|
query_params["locale"] = locale
|
|
44
70
|
return super().get_resource(resource, region, query_params)
|
|
45
|
-
|
|
71
|
+
|
|
46
72
|
# Ladder API
|
|
47
|
-
|
|
48
|
-
def get_grandmaster_leaderboard(
|
|
73
|
+
|
|
74
|
+
def get_grandmaster_leaderboard(
|
|
75
|
+
self, region: str, locale: str, region_id: int
|
|
76
|
+
) -> Dict[str, Any]:
|
|
49
77
|
"""Returns ladder data for the current season's grandmaster leaderboard."""
|
|
50
78
|
resource = f"/sc2/ladder/grandmaster{region_id}"
|
|
51
79
|
query_params = {"locale": locale}
|
|
@@ -56,10 +84,10 @@ class Starcraft2CommunityApi(Api):
|
|
|
56
84
|
resource = f"/sc2/ladder/season/{region_id}"
|
|
57
85
|
query_params = {"locale": locale}
|
|
58
86
|
return super().get_resource(resource, region, query_params)
|
|
59
|
-
|
|
87
|
+
|
|
60
88
|
# Account API
|
|
61
89
|
def get_player(self, region: str, locale: str, account_id: int) -> Dict[str, Any]:
|
|
62
90
|
"""Returns metadata for an individual's account."""
|
|
63
91
|
resource = f"/sc2/player/{account_id}"
|
|
64
92
|
query_params = {"locale": locale}
|
|
65
|
-
return super().get_resource(resource, region, query_params)
|
|
93
|
+
return super().get_resource(resource, region, query_params)
|
{blizzardapi2-0.1.3 → blizzardapi2-0.1.4}/blizzardapi2/starcraft2/starcraft2_game_data_api.py
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""starcraft2_game_data_api.py file."""
|
|
2
|
+
|
|
2
3
|
from typing import Dict, Any
|
|
3
4
|
from ..api import Api
|
|
4
5
|
|
|
@@ -14,10 +15,12 @@ class Starcraft2GameDataApi(Api):
|
|
|
14
15
|
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
15
16
|
"""Init Starcraft2Api."""
|
|
16
17
|
super().__init__(client_id, client_secret)
|
|
17
|
-
|
|
18
|
-
# StarCraft II League API
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
# StarCraft II League API
|
|
20
|
+
|
|
21
|
+
def get_league_data(
|
|
22
|
+
self, region: str, season_id: int, queue_id: int, team_type: int, league_id: int
|
|
23
|
+
) -> Dict[str, Any]:
|
|
21
24
|
"""Returns data for the specified season, queue, team, and league.
|
|
22
25
|
|
|
23
26
|
queueId: the standard available queueIds are: 1=WoL 1v1, 2=WoL 2v2, 3=WoL 3v3, 4=WoL 4v4, 101=HotS 1v1, 102=HotS 2v2, 103=HotS 3v3, 104=HotS 4v4, 201=LotV 1v1, 202=LotV 2v2, 203=LotV 3v3, 204=LotV 4v4, 206=LotV Archon. Note that other available queues may not be listed here.
|
|
@@ -27,4 +30,4 @@ class Starcraft2GameDataApi(Api):
|
|
|
27
30
|
leagueId: available leagueIds are: 0=Bronze, 1=Silver, 2=Gold, 3=Platinum, 4=Diamond, 5=Master, 6=Grandmaster.
|
|
28
31
|
"""
|
|
29
32
|
resource = f"/data/sc2/league/{season_id}/{queue_id}/{team_type}/{league_id}"
|
|
30
|
-
return super().get_resource(resource, region)
|
|
33
|
+
return super().get_resource(resource, region)
|