77
88api = handler .api
99
10- router = APIRouter (tags = ["raw" ])
10+ router = APIRouter (
11+ prefix = "/raw" ,
12+ tags = ["raw" ],
13+ responses = {404 : {"description" : "Not found" }},
14+ )
1115
1216
13- @router .get ("/all" , include_in_schema = False )
14- @router .get ("/raw/all" , status_code = 200 )
15- async def get_all_raw (request : Request , source : str = "" ):
17+ @router .get ("/all" , status_code = 200 )
18+ async def get_all_raw (request : Request ):
1619 """
1720 All AHGS API Calls Only\n
1821 Note: Updates from Steam News are parsed from BBCode to Markdown.\n
@@ -21,27 +24,147 @@ async def get_all_raw(request: Request, source: str = ""):
2124 the proper authentication we have to rely on rednecked solutions.\n
2225 """
2326 await api .update_all ()
27+ no_include = [
28+ "items" ,
29+ "store_rotation" ,
30+ "mission_rewards" ,
31+ "level_spec" ,
32+ "score_calc" ,
33+ "season_pass" ,
34+ "season_pass_hm" ,
35+ "season_pass_sv" ,
36+ "season_pass_ce" ,
37+ "season_pass_dd" ,
38+ "minigame_leaderboard" ,
39+ "player_leaderboard" ,
40+ "commend_leaderboard" ,
41+ "election_policies" ,
42+ "election_candidates" ,
43+ ]
2444 data = {}
25- for i , ( k , v ) in enumerate ( api .raw_data .items () ):
26- if v ["data" ] is not [] or {} :
45+ for k , v in api .raw_data .items ():
46+ if v ["data" ] and k not in no_include :
2747 data [k ] = v ["data" ]
28- log .info (request , status .HTTP_200_OK , source )
48+ log .info (request , status .HTTP_200_OK )
2949 return data
3050
3151
32- @router .get ("/raw/planetstats" , include_in_schema = False )
33- async def redirect_planetstats ():
34- return RedirectResponse ("/raw/planet_stats" )
52+ @router .get ("/status" , status_code = 200 )
53+ async def redirect_planetstats (request : Request ):
54+ log .info (request , status .HTTP_200_OK )
55+ await api .fetch_data (info_name = "status" )
56+ data = api .raw_data ["status" ].get ("data" )
57+ if data :
58+ return data
59+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
60+
61+
62+ @router .get ("/war_info" , status_code = 200 )
63+ async def redirect_planetstats (request : Request ):
64+ log .info (request , status .HTTP_200_OK )
65+ await api .fetch_data (info_name = "war_info" )
66+ data = api .raw_data ["war_info" ].get ("data" )
67+ if data :
68+ return data
69+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
3570
3671
37- @router .get ("/raw/{data_id}" , status_code = 200 )
38- async def get_raw (request : Request , data_id : str , source : str = "" ):
39- """Return api data where id is the key value found in `/raw/all`\n
40- Example: `/raw/status` would return the status from `/raw/all`\n
41- Note: Updates from Steam News are parsed from BBCode to Markdown."""
42- log .info (request , status .HTTP_200_OK , source )
43- if data_id in api .raw_data .keys ():
44- await api .fetch_data (info_name = data_id )
45- data = api .raw_data [data_id ].get ("data" )
72+ @router .get ("/planetstats" , include_in_schema = False )
73+ @router .get ("/planet_stats" )
74+ async def redirect_planetstats (request : Request ):
75+ log .info (request , status .HTTP_200_OK )
76+ await api .fetch_data (info_name = "planet_stats" )
77+ data = api .raw_data ["planet_stats" ].get ("data" )
78+ if data :
4679 return data
4780 raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
81+
82+
83+ @router .get ("/major_order" , status_code = 200 )
84+ async def redirect_planetstats (request : Request ):
85+ log .info (request , status .HTTP_200_OK )
86+ await api .fetch_data (info_name = "major_order" )
87+ data = api .raw_data ["major_order" ].get ("data" )
88+ if data :
89+ return data
90+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
91+
92+
93+ @router .get ("/news_feed" , status_code = 200 )
94+ async def redirect_planetstats (request : Request ):
95+ log .info (request , status .HTTP_200_OK )
96+ await api .fetch_data (info_name = "news_feed" )
97+ data = api .raw_data ["news_feed" ].get ("data" )
98+ if data :
99+ return data
100+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
101+
102+
103+ @router .get ("/updates" , status_code = 200 )
104+ async def redirect_planetstats (request : Request ):
105+ log .info (request , status .HTTP_200_OK )
106+ await api .fetch_data (info_name = "updates" )
107+ data = api .raw_data ["updates" ].get ("data" )
108+ if data :
109+ return data
110+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
111+
112+
113+ @router .get ("/war_id" , status_code = 200 )
114+ async def redirect_planetstats (request : Request ):
115+ log .info (request , status .HTTP_200_OK )
116+ await api .fetch_data (info_name = "war_id" )
117+ data = api .raw_data ["war_id" ].get ("data" )
118+ if data :
119+ return data
120+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
121+
122+
123+ @router .get ("/items" , status_code = 200 )
124+ async def redirect_planetstats (request : Request ):
125+ log .info (request , status .HTTP_200_OK )
126+ await api .fetch_data (info_name = "war_id" )
127+ data = api .raw_data ["war_id" ].get ("data" )
128+ if data :
129+ return data
130+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
131+
132+
133+ @router .get ("/minigame_leaderboard" , status_code = 200 )
134+ async def redirect_planetstats (request : Request ):
135+ log .info (request , status .HTTP_200_OK )
136+ await api .fetch_data (info_name = "minigame_leaderboard" )
137+ data = api .raw_data ["minigame_leaderboard" ].get ("data" )
138+ if data :
139+ return data
140+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
141+
142+
143+ @router .get ("/player_leaderboard" , status_code = 200 )
144+ async def redirect_planetstats (request : Request ):
145+ log .info (request , status .HTTP_200_OK )
146+ await api .fetch_data (info_name = "player_leaderboard" )
147+ data = api .raw_data ["player_leaderboard" ].get ("data" )
148+ if data :
149+ return data
150+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
151+
152+
153+ @router .get ("/commend_leaderboard" , status_code = 200 )
154+ async def redirect_planetstats (request : Request ):
155+ log .info (request , status .HTTP_200_OK )
156+ await api .fetch_data (info_name = "commend_leaderboard" )
157+ data = api .raw_data ["commend_leaderboard" ].get ("data" )
158+ if data :
159+ return data
160+ raise HTTPException (status_code = status .HTTP_400_BAD_REQUEST )
161+
162+
163+ @router .get ("/clan_leaderboard" , status_code = 200 )
164+ async def redirect_planetstats (request : Request ):
165+ log .info (request , status .HTTP_200_OK )
166+ await api .fetch_data (info_name = "clan_leaderboard" )
167+ data = api .raw_data ["clan_leaderboard" ].get ("data" )
168+ if not data :
169+ return {}
170+ return data
0 commit comments