blizzardapi2 0.1.1__tar.gz → 0.1.2__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.1 → blizzardapi2-0.1.2}/PKG-INFO +3 -1
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/README.md +2 -0
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/api.py +9 -8
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/battlenet/battlenet_api.py +2 -1
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/battlenet/battlenet_oauth_api.py +2 -2
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/blizzard_api.py +3 -1
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/diablo3/diablo3_api.py +3 -2
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/diablo3/diablo3_community_api.py +18 -16
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/diablo3/diablo3_game_data_api.py +11 -9
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/hearthstone/hearthstone_api.py +3 -2
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/hearthstone/hearthstone_game_data_api.py +12 -9
- blizzardapi2-0.1.2/blizzardapi2/starcraft2/starcraft2_api.py +18 -0
- blizzardapi2-0.1.2/blizzardapi2/starcraft2/starcraft2_community_api.py +65 -0
- blizzardapi2-0.1.2/blizzardapi2/starcraft2/starcraft2_game_data_api.py +30 -0
- blizzardapi2-0.1.2/blizzardapi2/wow/__init__.py +1 -0
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/wow/wow_api.py +3 -2
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/wow/wow_game_data_api.py +300 -140
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/wow/wow_profile_api.py +60 -51
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/pyproject.toml +1 -1
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/LICENSE +0 -0
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/__init__.py +0 -0
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/battlenet/__init__.py +0 -0
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/diablo3/__init__.py +0 -0
- {blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/hearthstone/__init__.py +0 -0
- {blizzardapi2-0.1.1/blizzardapi2/wow → blizzardapi2-0.1.2/blizzardapi2/starcraft2}/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: blizzardapi2
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.2
|
|
4
4
|
Summary: A Python wrapper for Blizzard API
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Your Name
|
|
@@ -21,6 +21,8 @@ Description-Content-Type: text/markdown
|
|
|
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/) and I'm trying to update it and keep its packages managed.
|
|
23
23
|
|
|
24
|
+
It currently has the exact same functionality as the original version, but with updated dependencies. As I go through Blizzard's API categories, I'll update the library as necessary.
|
|
25
|
+
|
|
24
26
|
Current supported features include:
|
|
25
27
|
- Battle.net User
|
|
26
28
|
- Wow Profile
|
|
@@ -3,6 +3,8 @@
|
|
|
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/) and I'm trying to update it and keep its packages managed.
|
|
5
5
|
|
|
6
|
+
It currently has the exact same functionality as the original version, but with updated dependencies. As I go through Blizzard's API categories, I'll update the library as necessary.
|
|
7
|
+
|
|
6
8
|
Current supported features include:
|
|
7
9
|
- Battle.net User
|
|
8
10
|
- Wow Profile
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""api.py file."""
|
|
2
|
+
from typing import Dict, Any
|
|
2
3
|
import requests
|
|
3
4
|
|
|
4
5
|
|
|
@@ -16,7 +17,7 @@ class Api:
|
|
|
16
17
|
_session: An open requests.Session instance.
|
|
17
18
|
"""
|
|
18
19
|
|
|
19
|
-
def __init__(self, client_id, client_secret):
|
|
20
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
20
21
|
"""Init Api."""
|
|
21
22
|
self._client_id = client_id
|
|
22
23
|
self._client_secret = client_secret
|
|
@@ -30,7 +31,7 @@ class Api:
|
|
|
30
31
|
|
|
31
32
|
self._session = requests.Session()
|
|
32
33
|
|
|
33
|
-
def _get_client_token(self, region):
|
|
34
|
+
def _get_client_token(self, region: str) -> Dict[str, Any]:
|
|
34
35
|
"""Fetch an access token based on client id and client secret credentials.
|
|
35
36
|
|
|
36
37
|
Args:
|
|
@@ -48,11 +49,11 @@ class Api:
|
|
|
48
49
|
|
|
49
50
|
return self._response_handler(response)
|
|
50
51
|
|
|
51
|
-
def _response_handler(self, response):
|
|
52
|
+
def _response_handler(self, response: requests.Response) -> Dict[str, Any]:
|
|
52
53
|
"""Handle the response."""
|
|
53
54
|
return response.json()
|
|
54
55
|
|
|
55
|
-
def _request_handler(self, url, region, query_params):
|
|
56
|
+
def _request_handler(self, url: str, region: str, query_params: Dict[str, Any]) -> Dict[str, Any]:
|
|
56
57
|
"""Handle the request."""
|
|
57
58
|
if self._access_token is None:
|
|
58
59
|
json = self._get_client_token(region)
|
|
@@ -65,7 +66,7 @@ class Api:
|
|
|
65
66
|
|
|
66
67
|
return self._response_handler(response)
|
|
67
68
|
|
|
68
|
-
def _format_api_url(self, resource, region):
|
|
69
|
+
def _format_api_url(self, resource: str, region: str) -> str:
|
|
69
70
|
"""Format the API url into a usable url."""
|
|
70
71
|
if region == "cn":
|
|
71
72
|
url = self._api_url_cn.format(resource)
|
|
@@ -74,12 +75,12 @@ class Api:
|
|
|
74
75
|
|
|
75
76
|
return url
|
|
76
77
|
|
|
77
|
-
def get_resource(self, resource, region, query_params={}):
|
|
78
|
+
def get_resource(self, resource: str, region:str, query_params={}) -> Dict[str, Any]:
|
|
78
79
|
"""Direction handler for when fetching resources."""
|
|
79
80
|
url = self._format_api_url(resource, region)
|
|
80
81
|
return self._request_handler(url, region, query_params)
|
|
81
82
|
|
|
82
|
-
def _format_oauth_url(self, resource, region):
|
|
83
|
+
def _format_oauth_url(self, resource: str, region: str) -> str:
|
|
83
84
|
"""Format the oauth url into a usable url."""
|
|
84
85
|
if region == "cn":
|
|
85
86
|
url = self._oauth_url_cn.format(resource)
|
|
@@ -88,7 +89,7 @@ class Api:
|
|
|
88
89
|
|
|
89
90
|
return url
|
|
90
91
|
|
|
91
|
-
def get_oauth_resource(self, resource, region, query_params={}):
|
|
92
|
+
def get_oauth_resource(self, resource: str, region: str, query_params={}) -> Dict[str, Any]:
|
|
92
93
|
"""Direction handler for when fetching oauth resources."""
|
|
93
94
|
url = self._format_oauth_url(resource, region)
|
|
94
95
|
return self._request_handler(url, region, query_params)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""battlenet_api.py file."""
|
|
2
|
+
from typing import Dict, Any
|
|
2
3
|
from .battlenet_oauth_api import BattlenetOauthApi
|
|
3
4
|
|
|
4
5
|
|
|
@@ -10,6 +11,6 @@ class BattlenetApi:
|
|
|
10
11
|
client_secret: A string client secret supplied by Blizzard.
|
|
11
12
|
"""
|
|
12
13
|
|
|
13
|
-
def __init__(self, client_id, client_secret):
|
|
14
|
+
def __init__(self, client_id: str, client_secret: str) -> Dict[str, Any]:
|
|
14
15
|
"""Init BattlenetApi."""
|
|
15
16
|
self.oauth = BattlenetOauthApi(client_id, client_secret)
|
|
@@ -10,13 +10,13 @@ class BattlenetOauthApi(Api):
|
|
|
10
10
|
client_secret: A string client secret supplied by Blizzard.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
|
-
def __init__(self, client_id, client_secret):
|
|
13
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
14
14
|
"""Init BattlenetOauthApi."""
|
|
15
15
|
super().__init__(client_id, client_secret)
|
|
16
16
|
|
|
17
17
|
# User Authentication
|
|
18
18
|
|
|
19
|
-
def get_user_info(self, region, access_token):
|
|
19
|
+
def get_user_info(self, region: str, access_token: str) -> dict:
|
|
20
20
|
"""Return basic information about the user associated with the current bearer token."""
|
|
21
21
|
resource = "/oauth/userinfo"
|
|
22
22
|
query_params = {
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
from .battlenet.battlenet_api import BattlenetApi
|
|
3
3
|
from .diablo3.diablo3_api import Diablo3Api
|
|
4
4
|
from .hearthstone.hearthstone_api import HearthstoneApi
|
|
5
|
+
from .starcraft2.starcraft2_api import Starcraft2Api
|
|
5
6
|
from .wow.wow_api import WowApi
|
|
6
7
|
|
|
7
8
|
|
|
@@ -13,9 +14,10 @@ class BlizzardApi:
|
|
|
13
14
|
client_secret: A string client secret supplied by Blizzard.
|
|
14
15
|
"""
|
|
15
16
|
|
|
16
|
-
def __init__(self, client_id, client_secret):
|
|
17
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
17
18
|
"""Init BlizzardApi."""
|
|
18
19
|
self.battlenet = BattlenetApi(client_id, client_secret)
|
|
19
20
|
self.diablo3 = Diablo3Api(client_id, client_secret)
|
|
20
21
|
self.hearthstone = HearthstoneApi(client_id, client_secret)
|
|
21
22
|
self.wow = WowApi(client_id, client_secret)
|
|
23
|
+
self.starcraft2 = Starcraft2Api(client_id, client_secret)
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"""diablo3_api.py file."""
|
|
2
1
|
from .diablo3_community_api import Diablo3CommunityApi
|
|
3
2
|
from .diablo3_game_data_api import Diablo3GameDataApi
|
|
4
3
|
|
|
4
|
+
"""diablo3_api.py file."""
|
|
5
|
+
|
|
5
6
|
|
|
6
7
|
class Diablo3Api:
|
|
7
8
|
"""Diablo3 API class.
|
|
@@ -11,7 +12,7 @@ class Diablo3Api:
|
|
|
11
12
|
client_secret: A string client secret supplied by Blizzard.
|
|
12
13
|
"""
|
|
13
14
|
|
|
14
|
-
def __init__(self, client_id, client_secret):
|
|
15
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
15
16
|
"""Init Diablo3Api."""
|
|
16
17
|
self.community = Diablo3CommunityApi(client_id, client_secret)
|
|
17
18
|
self.game_data = Diablo3GameDataApi(client_id, client_secret)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
from typing import Dict, Any
|
|
2
2
|
from ..api import Api
|
|
3
3
|
|
|
4
|
+
"""diablo3_community_api.py file."""
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
class Diablo3CommunityApi(Api):
|
|
6
8
|
"""All Diablo 3 Community API methods.
|
|
@@ -10,19 +12,19 @@ class Diablo3CommunityApi(Api):
|
|
|
10
12
|
client_secret: A string client secret supplied by Blizzard.
|
|
11
13
|
"""
|
|
12
14
|
|
|
13
|
-
def __init__(self, client_id, client_secret):
|
|
15
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
14
16
|
"""Init Diablo3CommunityApi."""
|
|
15
17
|
super().__init__(client_id, client_secret)
|
|
16
18
|
|
|
17
19
|
# D3 Act API
|
|
18
20
|
|
|
19
|
-
def get_act_index(self, region, locale):
|
|
21
|
+
def get_act_index(self, region: str, locale: str) -> Dict[str, Any]:
|
|
20
22
|
"""Return an index of acts."""
|
|
21
23
|
resource = "/d3/data/act"
|
|
22
24
|
query_params = {"locale": locale}
|
|
23
25
|
return super().get_resource(resource, region, query_params)
|
|
24
26
|
|
|
25
|
-
def get_act(self, region, locale, act_id):
|
|
27
|
+
def get_act(self, region: str, locale: str, act_id: int) -> Dict[str, Any]:
|
|
26
28
|
"""Return a single act by ID."""
|
|
27
29
|
resource = f"/d3/data/act/{act_id}"
|
|
28
30
|
query_params = {"locale": locale}
|
|
@@ -30,13 +32,13 @@ class Diablo3CommunityApi(Api):
|
|
|
30
32
|
|
|
31
33
|
# D3 Artisan and Recipe API
|
|
32
34
|
|
|
33
|
-
def get_artisan(self, region, locale, artisan_slug):
|
|
35
|
+
def get_artisan(self, region: str, locale: str, artisan_slug: str) -> Dict[str, Any]:
|
|
34
36
|
"""Return a single artisan by slug."""
|
|
35
37
|
resource = f"/d3/data/artisan/{artisan_slug}"
|
|
36
38
|
query_params = {"locale": locale}
|
|
37
39
|
return super().get_resource(resource, region, query_params)
|
|
38
40
|
|
|
39
|
-
def get_recipe(self, region, locale, artisan_slug, recipe_slug):
|
|
41
|
+
def get_recipe(self, region: str, locale: str, artisan_slug: str, recipe_slug: str) -> Dict[str, Any]:
|
|
40
42
|
"""Return a single recipe by slug for the specified artisan."""
|
|
41
43
|
resource = f"/d3/data/artisan/{artisan_slug}/recipe/{recipe_slug}"
|
|
42
44
|
query_params = {"locale": locale}
|
|
@@ -44,7 +46,7 @@ class Diablo3CommunityApi(Api):
|
|
|
44
46
|
|
|
45
47
|
# D3 Follower API
|
|
46
48
|
|
|
47
|
-
def get_follower(self, region, locale, follower_slug):
|
|
49
|
+
def get_follower(self, region: str, locale: str, follower_slug: str) -> Dict[str, Any]:
|
|
48
50
|
"""Return a single follower by slug."""
|
|
49
51
|
resource = f"/d3/data/follower/{follower_slug}"
|
|
50
52
|
query_params = {"locale": locale}
|
|
@@ -52,13 +54,13 @@ class Diablo3CommunityApi(Api):
|
|
|
52
54
|
|
|
53
55
|
# D3 Character Class and Skill API
|
|
54
56
|
|
|
55
|
-
def get_character_class(self, region, locale, class_slug):
|
|
57
|
+
def get_character_class(self, region: str, locale: str, class_slug: str) -> Dict[str, Any]:
|
|
56
58
|
"""Return a single character class by slug."""
|
|
57
59
|
resource = f"/d3/data/hero/{class_slug}"
|
|
58
60
|
query_params = {"locale": locale}
|
|
59
61
|
return super().get_resource(resource, region, query_params)
|
|
60
62
|
|
|
61
|
-
def get_api_skill(self, region, locale, class_slug, skill_slug):
|
|
63
|
+
def get_api_skill(self, region: str, locale: str, class_slug: str, skill_slug: str) -> Dict[str, Any]:
|
|
62
64
|
"""Return a single skill by slug for a specific character class."""
|
|
63
65
|
resource = f"/d3/data/hero/{class_slug}/skill/{skill_slug}"
|
|
64
66
|
query_params = {"locale": locale}
|
|
@@ -66,13 +68,13 @@ class Diablo3CommunityApi(Api):
|
|
|
66
68
|
|
|
67
69
|
# D3 Item Type API
|
|
68
70
|
|
|
69
|
-
def get_item_type_index(self, region, locale):
|
|
71
|
+
def get_item_type_index(self, region: str, locale: str) -> Dict[str, Any]:
|
|
70
72
|
"""Return an index of item types."""
|
|
71
73
|
resource = "/d3/data/item-type"
|
|
72
74
|
query_params = {"locale": locale}
|
|
73
75
|
return super().get_resource(resource, region, query_params)
|
|
74
76
|
|
|
75
|
-
def get_item_type(self, region, locale, item_type_slug):
|
|
77
|
+
def get_item_type(self, region: str, locale: str, item_type_slug: str) -> Dict[str, Any]:
|
|
76
78
|
"""Return a single item type by slug."""
|
|
77
79
|
resource = f"/d3/data/item-type/{item_type_slug}"
|
|
78
80
|
query_params = {"locale": locale}
|
|
@@ -80,7 +82,7 @@ class Diablo3CommunityApi(Api):
|
|
|
80
82
|
|
|
81
83
|
# D3 Item API
|
|
82
84
|
|
|
83
|
-
def get_item(self, region, locale, item_slug_id):
|
|
85
|
+
def get_item(self, region: str, locale: str, item_slug_id: str) -> Dict[str, Any]:
|
|
84
86
|
"""Return a single item by item slug and ID."""
|
|
85
87
|
resource = f"/d3/data/item/{item_slug_id}"
|
|
86
88
|
query_params = {"locale": locale}
|
|
@@ -88,25 +90,25 @@ class Diablo3CommunityApi(Api):
|
|
|
88
90
|
|
|
89
91
|
# D3 Profile API
|
|
90
92
|
|
|
91
|
-
def get_api_account(self, region, locale, account_id):
|
|
93
|
+
def get_api_account(self, region: str, locale: str, account_id: str) -> Dict[str, Any]:
|
|
92
94
|
"""Return the specified account profile."""
|
|
93
95
|
resource = f"/d3/profile/{account_id}/"
|
|
94
96
|
query_params = {"locale": locale}
|
|
95
97
|
return super().get_resource(resource, region, query_params)
|
|
96
98
|
|
|
97
|
-
def get_api_hero(self, region, locale, account_id, hero_id):
|
|
99
|
+
def get_api_hero(self, region: str, locale: str, account_id: str, hero_id: int) -> Dict[str, Any]:
|
|
98
100
|
"""Return a single hero."""
|
|
99
101
|
resource = f"/d3/profile/{account_id}/hero/{hero_id}"
|
|
100
102
|
query_params = {"locale": locale}
|
|
101
103
|
return super().get_resource(resource, region, query_params)
|
|
102
104
|
|
|
103
|
-
def get_api_detailed_hero_items(self, region, locale, account_id, hero_id):
|
|
105
|
+
def get_api_detailed_hero_items(self, region: str, locale: str, account_id: str, hero_id: int) -> Dict[str, Any]:
|
|
104
106
|
"""Return a list of items for the specified hero."""
|
|
105
107
|
resource = f"/d3/profile/{account_id}/hero/{hero_id}/items"
|
|
106
108
|
query_params = {"locale": locale}
|
|
107
109
|
return super().get_resource(resource, region, query_params)
|
|
108
110
|
|
|
109
|
-
def get_api_detailed_follower_items(self, region, locale, account_id, hero_id):
|
|
111
|
+
def get_api_detailed_follower_items(self, region: str, locale: str, account_id: str, hero_id: int) -> Dict[str, Any]:
|
|
110
112
|
"""Return a single item by item slug and ID."""
|
|
111
113
|
resource = f"/d3/profile/{account_id}/hero/{hero_id}/follower-items"
|
|
112
114
|
query_params = {"locale": locale}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
from typing import List, Dict
|
|
2
2
|
from ..api import Api
|
|
3
3
|
|
|
4
|
+
"""diablo3_game_data_api.py file."""
|
|
5
|
+
|
|
4
6
|
|
|
5
7
|
class Diablo3GameDataApi(Api):
|
|
6
8
|
"""All Diablo 3 Game Data API methods.
|
|
@@ -10,38 +12,38 @@ class Diablo3GameDataApi(Api):
|
|
|
10
12
|
client_secret: A string client secret supplied by Blizzard.
|
|
11
13
|
"""
|
|
12
14
|
|
|
13
|
-
def __init__(self, client_id, client_secret):
|
|
15
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
14
16
|
"""Init Diablo3GameDataApi."""
|
|
15
17
|
super().__init__(client_id, client_secret)
|
|
16
18
|
|
|
17
19
|
# D3
|
|
18
20
|
|
|
19
|
-
def get_season_index(self, region):
|
|
21
|
+
def get_season_index(self, region: str) -> Dict:
|
|
20
22
|
"""Return an index of available seasons."""
|
|
21
23
|
resource = "/data/d3/season/"
|
|
22
24
|
return super().get_resource(resource, region)
|
|
23
25
|
|
|
24
|
-
def get_season(self, region, season_id):
|
|
26
|
+
def get_season(self, region: str, season_id: int) -> Dict:
|
|
25
27
|
"""Return a leaderboard list for the specified season."""
|
|
26
28
|
resource = f"/data/d3/season/{season_id}"
|
|
27
29
|
return super().get_resource(resource, region)
|
|
28
30
|
|
|
29
|
-
def get_season_leaderboard(self, region, season_id, leaderboard_id):
|
|
30
|
-
"""Return
|
|
31
|
+
def get_season_leaderboard(self, region: str, season_id: int, leaderboard_id: int) -> Dict:
|
|
32
|
+
"""Return the specified leaderboard for the specified season."""
|
|
31
33
|
resource = f"/data/d3/season/{season_id}/leaderboard/{leaderboard_id}"
|
|
32
34
|
return super().get_resource(resource, region)
|
|
33
35
|
|
|
34
|
-
def get_era_index(self, region):
|
|
36
|
+
def get_era_index(self, region: str) -> Dict:
|
|
35
37
|
"""Return an index of available eras."""
|
|
36
38
|
resource = "/data/d3/era/"
|
|
37
39
|
return super().get_resource(resource, region)
|
|
38
40
|
|
|
39
|
-
def get_era(self, region, era_id):
|
|
41
|
+
def get_era(self, region: str, era_id: int) -> Dict:
|
|
40
42
|
"""Return a leaderboard list for a particular era."""
|
|
41
43
|
resource = f"/data/d3/era/{era_id}"
|
|
42
44
|
return super().get_resource(resource, region)
|
|
43
45
|
|
|
44
|
-
def get_era_leaderboard(self, region, era_id, leaderboard_id):
|
|
46
|
+
def get_era_leaderboard(self, region: str, era_id: int, leaderboard_id: int) -> Dict:
|
|
45
47
|
"""Return the specified leaderboard for the specified era."""
|
|
46
48
|
resource = f"/data/d3/era/{era_id}/leaderboard/{leaderboard_id}"
|
|
47
49
|
return super().get_resource(resource, region)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
"""hearthstone_api.py file."""
|
|
2
1
|
from .hearthstone_game_data_api import HearthstoneGameDataApi
|
|
3
2
|
|
|
3
|
+
"""hearthstone_api.py file."""
|
|
4
|
+
|
|
4
5
|
|
|
5
6
|
class HearthstoneApi:
|
|
6
7
|
"""Hearthstone API class.
|
|
@@ -10,6 +11,6 @@ class HearthstoneApi:
|
|
|
10
11
|
client_secret: A string client secret supplied by Blizzard.
|
|
11
12
|
"""
|
|
12
13
|
|
|
13
|
-
def __init__(self, client_id, client_secret):
|
|
14
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
14
15
|
"""Init HearthstoneApi."""
|
|
15
16
|
self.game_data = HearthstoneGameDataApi(client_id, client_secret)
|
{blizzardapi2-0.1.1 → blizzardapi2-0.1.2}/blizzardapi2/hearthstone/hearthstone_game_data_api.py
RENAMED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
from typing import Any, Dict
|
|
2
2
|
from ..api import Api
|
|
3
3
|
|
|
4
|
+
"""hearthstone_game_data_api.py file."""
|
|
5
|
+
|
|
6
|
+
|
|
4
7
|
|
|
5
8
|
class HearthstoneGameDataApi(Api):
|
|
6
9
|
"""All Hearthstone Game Data API methods.
|
|
@@ -10,19 +13,19 @@ class HearthstoneGameDataApi(Api):
|
|
|
10
13
|
client_secret: A string client secret supplied by Blizzard.
|
|
11
14
|
"""
|
|
12
15
|
|
|
13
|
-
def __init__(self, client_id, client_secret):
|
|
16
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
14
17
|
"""Init HearthstoneGameDataApi."""
|
|
15
18
|
super().__init__(client_id, client_secret)
|
|
16
19
|
|
|
17
20
|
# Cards
|
|
18
21
|
|
|
19
|
-
def search_cards(self, region, locale, **query_params):
|
|
22
|
+
def search_cards(self, region: str, locale: str, **query_params: Any) -> Dict[str, Any]:
|
|
20
23
|
"""Return an up-to-date list of all cards matching the search criteria."""
|
|
21
24
|
resource = "/hearthstone/cards"
|
|
22
25
|
query_params.update({"locale": locale})
|
|
23
26
|
return super().get_resource(resource, region, query_params)
|
|
24
27
|
|
|
25
|
-
def get_card(self, region, locale, id_or_slug, game_mode="constructed"):
|
|
28
|
+
def get_card(self, region: str, locale: str, id_or_slug: str, game_mode: str = "constructed") -> Dict[str, Any]:
|
|
26
29
|
"""Return the card with an ID or slug that matches the one you specify."""
|
|
27
30
|
resource = f"/hearthstone/cards/{id_or_slug}"
|
|
28
31
|
query_params = {"locale": locale, "game_mode": game_mode}
|
|
@@ -30,13 +33,13 @@ class HearthstoneGameDataApi(Api):
|
|
|
30
33
|
|
|
31
34
|
# Card Backs
|
|
32
35
|
|
|
33
|
-
def search_card_backs(self, region, locale, **query_params):
|
|
36
|
+
def search_card_backs(self, region: str, locale: str, **query_params: Any) -> Dict[str, Any]:
|
|
34
37
|
"""Return an up-to-date list of all card backs matching the search criteria."""
|
|
35
38
|
resource = "/hearthstone/cardbacks"
|
|
36
39
|
query_params.update({"locale": locale})
|
|
37
40
|
return super().get_resource(resource, region, query_params)
|
|
38
41
|
|
|
39
|
-
def get_card_back(self, region, locale, id_or_slug):
|
|
42
|
+
def get_card_back(self, region: str, locale: str, id_or_slug: str) -> Dict[str, Any]:
|
|
40
43
|
"""Return a specific card back by using card back ID or slug."""
|
|
41
44
|
resource = f"/hearthstone/cardbacks/{id_or_slug}"
|
|
42
45
|
query_params = {"locale": locale}
|
|
@@ -44,7 +47,7 @@ class HearthstoneGameDataApi(Api):
|
|
|
44
47
|
|
|
45
48
|
# Decks
|
|
46
49
|
|
|
47
|
-
def get_deck(self, region, locale, **query_params):
|
|
50
|
+
def get_deck(self, region: str, locale: str, **query_params: Any) -> Dict[str, Any]:
|
|
48
51
|
"""Find a deck by list of cards or code, including the hero."""
|
|
49
52
|
resource = "/hearthstone/deck"
|
|
50
53
|
query_params = {"locale": locale}
|
|
@@ -52,13 +55,13 @@ class HearthstoneGameDataApi(Api):
|
|
|
52
55
|
|
|
53
56
|
# Metadata
|
|
54
57
|
|
|
55
|
-
def get_metadata(self, region, locale):
|
|
58
|
+
def get_metadata(self, region: str, locale: str) -> Dict[str, Any]:
|
|
56
59
|
"""Return information about the categorization of cards."""
|
|
57
60
|
resource = "/hearthstone/metadata"
|
|
58
61
|
query_params = {"locale": locale}
|
|
59
62
|
return super().get_resource(resource, region, query_params)
|
|
60
63
|
|
|
61
|
-
def get_metadata_type(self, region, locale, type_id):
|
|
64
|
+
def get_metadata_type(self, region: str, locale: str, type_id: str) -> Dict[str, Any]:
|
|
62
65
|
"""Return information about just one type of metadata."""
|
|
63
66
|
resource = f"/hearthstone/metadata/{type_id}"
|
|
64
67
|
query_params = {"locale": locale}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from .starcraft2_community_api import Starcraft2CommunityApi
|
|
2
|
+
from .starcraft2_game_data_api import Starcraft2GameDataApi
|
|
3
|
+
|
|
4
|
+
"""starcraft2_api.py file."""
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class Starcraft2Api:
|
|
8
|
+
"""Starcraft2 API class.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
client_id: A string client id supplied by Blizzard.
|
|
12
|
+
client_secret: A string client secret supplied by Blizzard.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
16
|
+
"""Init Starcraft2."""
|
|
17
|
+
self.community: Starcraft2CommunityApi = Starcraft2CommunityApi(client_id, client_secret)
|
|
18
|
+
self.game_data: Starcraft2GameDataApi = Starcraft2GameDataApi(client_id, client_secret)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""starcraft2_community_api.py file."""
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
from ..api import Api
|
|
4
|
+
|
|
5
|
+
class Starcraft2CommunityApi(Api):
|
|
6
|
+
"""All Starcraft 2 Community API methods.
|
|
7
|
+
Attributes:
|
|
8
|
+
client_id: A string client id supplied by Blizzard.
|
|
9
|
+
client_secret: A string client secret supplied by Blizzard.
|
|
10
|
+
"""
|
|
11
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
12
|
+
"""Init Starcraft2CommunityApi."""
|
|
13
|
+
super().__init__(client_id, client_secret)
|
|
14
|
+
|
|
15
|
+
# Profile API
|
|
16
|
+
def get_static(self, region: str, locale: str, region_id: int) -> Dict[str, Any]:
|
|
17
|
+
"""Returns all static SC2 profile data (achievements, categories, criteria, and rewards)."""
|
|
18
|
+
resource = f"/sc2/static/profile/{region_id}"
|
|
19
|
+
query_params = {"locale": locale}
|
|
20
|
+
return super().get_resource(resource, region, query_params)
|
|
21
|
+
|
|
22
|
+
def get_metadata(self, region: str, locale: str, region_id: int, realm_id: int, profile_id: int) -> Dict[str, Any]:
|
|
23
|
+
"""Returns metadata for an individual's profile."""
|
|
24
|
+
resource = f"/sc2/metadata/profile/{region_id}/{realm_id}/{profile_id}"
|
|
25
|
+
query_params = {"locale": locale}
|
|
26
|
+
return super().get_resource(resource, region, query_params)
|
|
27
|
+
|
|
28
|
+
def get_profile(self, region: str, locale: str, region_id: int, realm_id: int, profile_id: int, **query_params: Any) -> Dict[str, Any]:
|
|
29
|
+
"""Returns data about an individual SC2 profile."""
|
|
30
|
+
resource = f"/sc2/profile/{region_id}/{realm_id}/{profile_id}"
|
|
31
|
+
query_params["locale"] = locale
|
|
32
|
+
return super().get_resource(resource, region, query_params)
|
|
33
|
+
|
|
34
|
+
def get_ladder_summary(self, region: str, locale: str, region_id: int, realm_id: int, profile_id: int) -> Dict[str, Any]:
|
|
35
|
+
"""Returns a ladder summary for an individual SC2 profile."""
|
|
36
|
+
resource = f"/sc2/profile/{region_id}/{realm_id}/{profile_id}/ladder/summary"
|
|
37
|
+
query_params = {"locale": locale}
|
|
38
|
+
return super().get_resource(resource, region, query_params)
|
|
39
|
+
|
|
40
|
+
def get_ladder(self, region: str, locale: str, region_id: int, realm_id: int, profile_id: int, ladder_id: int, **query_params: Any) -> Dict[str, Any]:
|
|
41
|
+
"""Returns data about an individual profile's ladder."""
|
|
42
|
+
resource = f"/sc2/profile/{region_id}/{realm_id}/{profile_id}/ladder/{ladder_id}"
|
|
43
|
+
query_params["locale"] = locale
|
|
44
|
+
return super().get_resource(resource, region, query_params)
|
|
45
|
+
|
|
46
|
+
# Ladder API
|
|
47
|
+
|
|
48
|
+
def get_grandmaster_leaderboard(self, region: str, locale: str, region_id: int) -> Dict[str, Any]:
|
|
49
|
+
"""Returns ladder data for the current season's grandmaster leaderboard."""
|
|
50
|
+
resource = f"/sc2/ladder/grandmaster{region_id}"
|
|
51
|
+
query_params = {"locale": locale}
|
|
52
|
+
return super().get_resource(resource, region, query_params)
|
|
53
|
+
|
|
54
|
+
def get_season(self, region: str, locale: str, region_id: int) -> Dict[str, Any]:
|
|
55
|
+
"""Returns data about the current season."""
|
|
56
|
+
resource = f"/sc2/ladder/season/{region_id}"
|
|
57
|
+
query_params = {"locale": locale}
|
|
58
|
+
return super().get_resource(resource, region, query_params)
|
|
59
|
+
|
|
60
|
+
# Account API
|
|
61
|
+
def get_player(self, region: str, locale: str, account_id: int) -> Dict[str, Any]:
|
|
62
|
+
"""Returns metadata for an individual's account."""
|
|
63
|
+
resource = f"/sc2/player/{account_id}"
|
|
64
|
+
query_params = {"locale": locale}
|
|
65
|
+
return super().get_resource(resource, region, query_params)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""starcraft2_game_data_api.py file."""
|
|
2
|
+
from typing import Dict, Any
|
|
3
|
+
from ..api import Api
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class Starcraft2GameDataApi(Api):
|
|
7
|
+
"""Starcraft2 Game Data API class.
|
|
8
|
+
|
|
9
|
+
Attributes:
|
|
10
|
+
client_id: A string client id supplied by Blizzard.
|
|
11
|
+
client_secret: A string client secret supplied by Blizzard.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
15
|
+
"""Init Starcraft2Api."""
|
|
16
|
+
super().__init__(client_id, client_secret)
|
|
17
|
+
|
|
18
|
+
# StarCraft II League API
|
|
19
|
+
|
|
20
|
+
def get_league_data(self, region: str, season_id: int, queue_id: int, team_type: int, league_id: int) -> Dict[str, Any]:
|
|
21
|
+
"""Returns data for the specified season, queue, team, and league.
|
|
22
|
+
|
|
23
|
+
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.
|
|
24
|
+
|
|
25
|
+
teamType: there are two available teamTypes: 0=arranged, 1=random.
|
|
26
|
+
|
|
27
|
+
leagueId: available leagueIds are: 0=Bronze, 1=Silver, 2=Gold, 3=Platinum, 4=Diamond, 5=Master, 6=Grandmaster.
|
|
28
|
+
"""
|
|
29
|
+
resource = f"/data/sc2/league/{season_id}/{queue_id}/{team_type}/{league_id}"
|
|
30
|
+
return super().get_resource(resource, region)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""__init__.py file."""
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
"""wow_api.py file."""
|
|
2
1
|
from .wow_game_data_api import WowGameDataApi
|
|
3
2
|
from .wow_profile_api import WowProfileApi
|
|
4
3
|
|
|
4
|
+
"""wow_api.py file."""
|
|
5
|
+
|
|
5
6
|
|
|
6
7
|
class WowApi:
|
|
7
8
|
"""Wow API class.
|
|
@@ -11,7 +12,7 @@ class WowApi:
|
|
|
11
12
|
client_secret: A string client secret supplied by Blizzard.
|
|
12
13
|
"""
|
|
13
14
|
|
|
14
|
-
def __init__(self, client_id, client_secret):
|
|
15
|
+
def __init__(self, client_id: str, client_secret: str) -> None:
|
|
15
16
|
"""Init WowApi."""
|
|
16
17
|
self.game_data = WowGameDataApi(client_id, client_secret)
|
|
17
18
|
self.profile = WowProfileApi(client_id, client_secret)
|