Skip to content

Commit 2a67558

Browse files
authored
Merge pull request #4 from thatOneArchUser/main
Fix errors related to returning API endpoint data
2 parents 0e82cf0 + 1e31bd8 commit 2a67558

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

api.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@ def __init__(self, api_key: str):
1010

1111
def get_uuid(self, player_name: str) -> str:
1212
api_request = requests.get(f"https://api.mojang.com/users/profiles/minecraft/{player_name}")
13-
return api_request.text
13+
content = json.loads(api_request.content)
14+
return content["id"]
1415

1516
# API Retrieval Commands
16-
def get_auctions(self, *, page: int = 0):
17+
def get_auctions(self, page: int = 0):
1718
"""
1819
Returns a `dict` of the 1000 latest auctions in Skyblock.
1920
2021
Optional args:
2122
* `page`: View a specific page of auctions.
2223
"""
23-
api_request = requests.get(f"https://api.hypixel.net/skyblock/auctions?key={self.api_key}&page={page}")
24+
api_request = requests.get(f"https://api.hypixel.net/skyblock/auctions?key={self.api_key}&page={page}").content
2425
auctions = json.loads(api_request)
2526
return auctions
2627

@@ -29,23 +30,23 @@ def get_player_auctions(self, player_name: str):
2930
Returns a `dict` of all Skyblock auctions from a particular player.
3031
"""
3132
player_uuid = self.get_uuid(player_name)
32-
api_request = requests.get(f"https://api.hypixel.net/skyblock/auction?key={self.api_key}&player={player_uuid}")
33+
api_request = requests.get(f"https://api.hypixel.net/skyblock/auction?key={self.api_key}&player={player_uuid}").content
3334
player_auctions = json.loads(api_request)
3435
return player_auctions
3536

3637
def get_news(self):
3738
"""
3839
Returns a `dict` of the latest Skyblock news from Hypixel.
3940
"""
40-
api_request = requests.get(f"https://api.hypixel.net/skyblock/news?key={self.api_key}")
41+
api_request = requests.get(f"https://api.hypixel.net/skyblock/news?key={self.api_key}").content
4142
news = json.loads(api_request)
4243
return news
4344

4445
def get_bazaar_data(self):
4546
"""
4647
Returns a `dict` of Skyblock bazaar data.
4748
"""
48-
api_request = requests.get(f"https://api.hypixel.net/skyblock/bazaar?key={self.api_key}")
49+
api_request = requests.get(f"https://api.hypixel.net/skyblock/bazaar?key={self.api_key}").content
4950
bazaar_data = json.loads(api_request)
5051
return bazaar_data
5152

@@ -54,22 +55,22 @@ def get_player_profile(self, player_name: str):
5455
Returns a `dict` of profile data on a player.
5556
"""
5657
player_uuid = self.get_uuid(player_name)
57-
api_request = requests.get(f"https://api.hypixel.net/skyblock/profiles?key={self.api_key}&uuid={player_uuid}")
58+
api_request = requests.get(f"https://api.hypixel.net/skyblock/profiles?key={self.api_key}&uuid={player_uuid}").content
5859
player_profile_data = json.loads(api_request)
5960
return player_profile_data
6061

6162
def get_collections(self):
6263
"""
6364
Returns a `dict` of information related to Skyblock Collections.
6465
"""
65-
api_request = requests.get("https://api.hypixel.net/resources/skyblock/collections")
66+
api_request = requests.get("https://api.hypixel.net/resources/skyblock/collections").content
6667
collections_data = json.loads(api_request)
6768
return collections_data
6869

6970
def get_skills(self):
7071
"""
7172
Returns a `dict` of information related to Skyblock Skills.
7273
"""
73-
api_request = requests.get("https://api.hypixel.net/resources/skyblock/skills")
74+
api_request = requests.get("https://api.hypixel.net/resources/skyblock/skills").content
7475
collections_data = json.loads(api_request)
7576
return collections_data

0 commit comments

Comments
 (0)