Skip to content

Commit b679376

Browse files
authored
Initial commit
1 parent 3032373 commit b679376

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"""
2+
### A simple API wrapper for Hypixel Skyblock.
3+
4+
(c) 2023-present NKA Development Organization
5+
"""
6+
7+
from . import api

api.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
"""Used for accessing the Skyblock API."""
2+
import requests
3+
import json
4+
5+
class Skyblock:
6+
def __init__(self, api_key: str):
7+
self.api_key = api_key
8+
9+
def get_uuid(self, player_name: str) -> str:
10+
api_request = requests.get(f"https://api.mojang.com/users/profiles/minecraft/{player_name}")
11+
return api_request.text
12+
13+
# Make API retrieval commands here
14+
def get_auctions(self, *, player_name: str = None):
15+
"""
16+
Returns a `dict` of the 1000 latest auctions in Skyblock.
17+
18+
Optional args:
19+
* `player_name`: Shows auctions only from that player.
20+
"""
21+
if player_name is not None:
22+
player_uuid = self.get_uuid(player_name)
23+
api_request = requests.get(f"https://api.hypixel.net/skyblock/auction?key={self.api_key}&player={player_uuid}")
24+
return api_request.text
25+
else:
26+
api_request = requests.get(f"https://api.hypixel.net/skyblock/auctions?key={self.api_key}")
27+
auctions = json.loads(api_request)
28+
return auctions
29+
30+
def get_news(self):
31+
"""
32+
Returns a `dict` of the latest Skyblock news from Hypixel.
33+
"""
34+
api_request = requests.get(f"https://api.hypixel.net/skyblock/news?key={self.api_key}")
35+
news = json.loads(api_request)
36+
return news
37+
38+
def get_bazaar_data(self):
39+
"""
40+
Returns a `dict` of Skyblock bazaar data.
41+
"""
42+
api_request = requests.get(f"https://api.hypixel.net/skyblock/bazaar?key={self.api_key}")
43+
bazaar_data = json.loads(api_request)
44+
return bazaar_data
45+
46+
def get_player_profile(self, player_name: str):
47+
"""
48+
Returns a `dict` of profile data on a player.
49+
"""
50+
player_uuid = self.get_uuid(player_name)
51+
api_request = requests.get(f"https://api.hypixel.net/skyblock/profiles?key={self.api_key}&uuid={player_uuid}")
52+
player_profile_data = json.loads(api_request)
53+
return player_profile_data

0 commit comments

Comments
 (0)