Skip to content

Commit 643dae3

Browse files
committed
Implement Games v1 & v2 (full coverage) API.
1 parent b9d87c8 commit 643dae3

File tree

1 file changed

+286
-0
lines changed

1 file changed

+286
-0
lines changed

pyblox3/src/games.py

Lines changed: 286 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,286 @@
1+
#
2+
# games.py
3+
# pyblox
4+
#
5+
# By Sanjay-B(Sanjay Bhadra)
6+
# Copyright © 2019- Sanjay-B(Sanjay Bhadra). All rights reserved.
7+
#
8+
9+
from .util import *
10+
import json
11+
12+
class Games_v1:
13+
14+
def __init__(self, **kwargs):
15+
auth = kwargs.get("auth", None)
16+
self.auth = auth.auth_cookies
17+
self.Favorites = self.Favorites(self)
18+
self.GamePasses = self.GamePasses(self)
19+
self.Votes = self.Votes(self)
20+
self.VipServers = self.VipServers(self)
21+
22+
# GET : "https://games.roblox.com/v1/games"
23+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games
24+
async def get(self):
25+
auth = self.auth
26+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games', cookies=auth)
27+
return response[4]
28+
29+
# GET : "https://games.roblox.com/v1/games/{placeId}/servers/{serverType}"
30+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games_placeId_servers_serverType
31+
async def getServers(self,**kwargs):
32+
auth = self.auth
33+
placeId = kwargs.get("placeId", None)
34+
serverType = kwargs.get("serverType", None)
35+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/{placeId}/servers/{serverType}', cookies=auth)
36+
return response[4]
37+
38+
# GET : "https://games.roblox.com/v1/games/games-product-info"
39+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games_games_product_info
40+
async def getProductInfoList(self):
41+
auth = self.auth
42+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/games-product-info', cookies=auth)
43+
return response[4]
44+
45+
# GET : "https://games.roblox.com/v1/games/list"
46+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games_list
47+
async def getGamesList(self):
48+
auth = self.auth
49+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/list', cookies=auth)
50+
return response[4]
51+
52+
# GET : "https://games.roblox.com/v1/games/list-spotlight"
53+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games_list_spotlight
54+
async def getGamesListSpotlight(self):
55+
auth = self.auth
56+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/list-spotlight', cookies=auth)
57+
return response[4]
58+
59+
# GET : "https://games.roblox.com/v1/games/multiget-place-details"
60+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games_multiget_place_details
61+
async def getMuliPlaceDetails(self):
62+
auth = self.auth
63+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/multiget-place-details', cookies=auth)
64+
return response[4]
65+
66+
# GET : "https://games.roblox.com/v1/games/multiget-playability-status"
67+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games_multiget_playability_status
68+
async def getMuliPlaceDetails(self):
69+
auth = self.auth
70+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/multiget-playability-status', cookies=auth)
71+
return response[4]
72+
73+
# GET : "https://games.roblox.com/v1/games/recommendations/algorithm/{algorithmName}"
74+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games_recommendations_algorithm_algorithmName
75+
async def getGameRecommendations(self,**kwargs):
76+
auth = self.auth
77+
algorithmName = kwargs.get("algorithmName", None)
78+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/recommendations/algorithm/{algorithmName}', cookies=auth)
79+
return response[4]
80+
81+
# GET : "https://games.roblox.com/v1/games/recommendations/game/{universeId}"
82+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games_recommendations_game_universeId
83+
async def getGameRecommendationByUniverse(self,**kwargs):
84+
auth = self.auth
85+
universeId = kwargs.get("universeId", None)
86+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/recommendations/game/{universeId}', cookies=auth)
87+
return response[4]
88+
89+
# GET : "https://games.roblox.com/v1/games/sorts"
90+
# Docs : https://games.roblox.com/docs#!/Games/get_v1_games_sorts
91+
async def getOrderedListSorts(self,**kwargs):
92+
auth = self.auth
93+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/sorts', cookies=auth)
94+
return response[4]
95+
96+
97+
class Favorites:
98+
99+
def __init__(self,Games_v1):
100+
self.Games_v1 = Games_v1
101+
self.auth = Games_v1.auth
102+
103+
# GET : "https://games.roblox.com/v1/games/{universeId}/favorites"
104+
# Docs : https://games.roblox.com/docs#!/Favorites/get_v1_games_universeId_favorites
105+
async def getbyUniverse(self,**kwargs):
106+
auth = self.auth
107+
universeId = kwargs.get("universeId", None)
108+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/{universeId}/favorites', cookies=auth)
109+
return response[4]
110+
111+
# POST : "https://games.roblox.com/v1/games/{universeId}/favorites"
112+
# Docs : https://games.roblox.com/docs#!/Favorites/post_v1_games_universeId_favorites
113+
async def mark(self,**kwargs):
114+
auth = self.auth
115+
universeId = kwargs.get("universeId", None)
116+
request = kwargs.get("request", None)
117+
response = await Req.request(t="POST", url=f'https://games.roblox.com/v1/games/{universeId}/favorites', payload=request, cookies=auth)
118+
if response[0] == 200:
119+
return True
120+
return False, response[4]
121+
122+
# GET : "https://games.roblox.com/v1/games/{universeId}/favorites/count"
123+
# Docs : https://games.roblox.com/docs#!/Favorites/get_v1_games_universeId_favorites_count
124+
async def getCountbyUniverse(self,**kwargs):
125+
auth = self.auth
126+
universeId = kwargs.get("universeId", None)
127+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/{universeId}/favorites/count', cookies=auth)
128+
return response[4]
129+
130+
131+
class GamePasses:
132+
133+
def __init__(self,Games_v1):
134+
self.Games_v1 = Games_v1
135+
self.auth = Games_v1.auth
136+
137+
# GET : "https://games.roblox.com/v1/games/{universeId}/game-passes"
138+
# Docs : https://games.roblox.com/docs#!/GamePasses/get_v1_games_universeId_game_passes
139+
async def getByUniverse(self,**kwargs):
140+
auth = self.auth
141+
universeId = kwargs.get("universeId", None)
142+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/{universeId}/game-passes', cookies=auth)
143+
return response[4]
144+
145+
class Votes:
146+
147+
def __init__(self,Games_v1):
148+
self.Games_v1 = Games_v1
149+
self.auth = Games_v1.auth
150+
151+
# GET : "https://games.roblox.com/v1/games/{universeId}/votes/user"
152+
# Docs : https://games.roblox.com/docs#!/Votes/get_v1_games_universeId_votes_user
153+
async def getByUniverse(self,**kwargs):
154+
auth = self.auth
155+
universeId = kwargs.get("universeId", None)
156+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/{universeId}/votes/user', cookies=auth)
157+
return response[4]
158+
159+
# GET : "https://games.roblox.com/v1/games/votes"
160+
# Docs : https://games.roblox.com/docs#!/Votes/get_v1_games_votes
161+
async def getVotes(self,**kwargs):
162+
auth = self.auth
163+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/games/votes', cookies=auth)
164+
return response[4]
165+
166+
# PATCH : "https://games.roblox.com/v1/games/{universeId}/user-votes"
167+
# Docs : https://games.roblox.com/docs#!/Votes/patch_v1_games_universeId_user_votes
168+
async def cast(self,**kwargs):
169+
auth = self.auth
170+
universeId = kwargs.get("universeId", None)
171+
requestBody = kwargs.get("requestBody", None)
172+
response = await Req.request(t="PATCH", url=f'https://games.roblox.com/v1/games/{universeId}/user-votes', payload=requestBody, cookies=auth)
173+
if response[0] == 200:
174+
return True
175+
return False, response[4]
176+
177+
class VipServers:
178+
179+
def __init__(self,Games_v1):
180+
self.Games_v1 = Games_v1
181+
self.auth = Games_v1.auth
182+
183+
# GET : "https://games.roblox.com/v1/vip-server/can-invite/{userId}"
184+
# Docs : https://games.roblox.com/docs#!/VipServers/get_v1_vip_server_can_invite_userId
185+
async def canJoin(self,**kwargs):
186+
auth = self.auth
187+
userId = kwargs.get("userId", None)
188+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/vip-server/can-invite/{userId}', cookies=auth)
189+
return response[4]
190+
191+
# GET : "https://games.roblox.com/v1/vip-servers/{id}"
192+
# Docs : https://games.roblox.com/docs#!/VipServers/get_v1_vip_servers_id
193+
async def get(self,**kwargs):
194+
auth = self.auth
195+
id = kwargs.get("id", None)
196+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v1/vip-servers/{id}', cookies=auth)
197+
return response[4]
198+
199+
# PATCH : "https://games.roblox.com/v1/vip-servers/{id}"
200+
# Docs : https://games.roblox.com/docs#!/VipServers/patch_v1_vip_servers_id
201+
async def update(self,**kwargs):
202+
auth = self.auth
203+
id = kwargs.get("id", None)
204+
request = kwargs.get("request", None)
205+
response = await Req.request(t="PATCH", url=f'https://games.roblox.com/v1/vip-servers/{id}', payload=request, cookies=auth)
206+
if response[0] == 200:
207+
return True
208+
return False, response[4]
209+
210+
# POST : "https://games.roblox.com/v1/games/vip-servers/{universeId}"
211+
# Docs : https://games.roblox.com/docs#!/VipServers/post_v1_games_vip_servers_universeId
212+
async def create(self,**kwargs):
213+
auth = self.auth
214+
universeId = kwargs.get("universeId", None)
215+
requestBody = kwargs.get("requestBody", None)
216+
response = await Req.request(t="POST", url=f'https://games.roblox.com/v1/games/vip-servers/{universeId}', payload=requestBody, cookies=auth)
217+
if response[0] == 200:
218+
return True
219+
return False, response[4]
220+
221+
# PATCH : "https://games.roblox.com/v1/vip-servers/{id}/permissions"
222+
# Docs : https://games.roblox.com/docs#!/VipServers/patch_v1_vip_servers_id_permissions
223+
async def updatePermissions(self,**kwargs):
224+
auth = self.auth
225+
id = kwargs.get("id", None)
226+
request = kwargs.get("request", None)
227+
response = await Req.request(t="PATCH", url=f'https://games.roblox.com/v1/vip-servers/{id}/permissions', payload=request, cookies=auth)
228+
if response[0] == 200:
229+
return True
230+
return False, response[4]
231+
232+
# PATCH : "https://games.roblox.com/v1/vip-servers/{id}/subscription"
233+
# Docs : https://games.roblox.com/docs#!/VipServers/patch_v1_vip_servers_id_subscription
234+
async def updateSubscriptionStatus(self,**kwargs):
235+
auth = self.auth
236+
id = kwargs.get("id", None)
237+
request = kwargs.get("request", None)
238+
response = await Req.request(t="PATCH", url=f'https://games.roblox.com/v1/vip-servers/{id}/subscription', payload=request, cookies=auth)
239+
if response[0] == 200:
240+
return True
241+
return False, response[4]
242+
243+
class Games_v2:
244+
245+
def __init__(self, **kwargs):
246+
auth = kwargs.get("auth", None)
247+
248+
# GET : "https://games.roblox.com/v2/games/{universeId}/media"
249+
# Docs : https://games.roblox.com/docs#!/Games/get_v2_games_universeId_media
250+
async def getMediaData(self,**kwargs):
251+
auth = self.auth
252+
universeId = kwargs.get("universeId", None)
253+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v2/games/{universeId}/media', cookies=auth)
254+
return response[4]
255+
256+
# GET : "https://games.roblox.com/v2/groups/{groupId}/games"
257+
# Docs : https://games.roblox.com/docs#!/Games/get_v2_groups_groupId_games
258+
async def getCreatedByGroup(self,**kwargs):
259+
auth = self.auth
260+
groupId = kwargs.get("groupId", None)
261+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v2/groups/{groupId}/games', cookies=auth)
262+
return response[4]
263+
264+
# GET : "https://games.roblox.com/v2/groups/{groupId}/gamesV2"
265+
# Docs : https://games.roblox.com/docs#!/Games/get_v2_groups_groupId_gamesV2
266+
async def getCreatedByGroupV2(self,**kwargs):
267+
auth = self.auth
268+
groupId = kwargs.get("groupId", None)
269+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v2/groups/{groupId}/gamesV2', cookies=auth)
270+
return response[4]
271+
272+
# GET : "https://games.roblox.com/v2/users/{userId}/favorite/games"
273+
# Docs : https://games.roblox.com/docs#!/Games/get_v2_users_userId_favorite_games
274+
async def getFavoriteByUser(self,**kwargs):
275+
auth = self.auth
276+
userId = kwargs.get("userId", None)
277+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v2/users/{userId}/favorite/games', cookies=auth)
278+
return response[4]
279+
280+
# GET : "https://games.roblox.com/v2/users/{userId}/games"
281+
# Docs : https://games.roblox.com/docs#!/Games/get_v2_users_userId_games
282+
async def getCreatedByUser(self,**kwargs):
283+
auth = self.auth
284+
userId = kwargs.get("userId", None)
285+
response = await Req.request(t="GET", url=f'https://games.roblox.com/v2/users/{userId}/games', cookies=auth)
286+
return response[4]

0 commit comments

Comments
 (0)