1+ package com .rajat_singh .leetcode_api .controller ;
2+
3+ import org .springframework .http .ResponseEntity ;
4+ import org .springframework .web .bind .annotation .GetMapping ;
5+ import org .springframework .web .bind .annotation .RequestMapping ;
6+ import org .springframework .web .bind .annotation .RestController ;
7+
8+ import java .util .LinkedHashMap ;
9+ import java .util .Map ;
10+
11+ /**
12+ * This controller provides a root "index" endpoint for the API,
13+ * documenting all available routes for users.
14+ */
15+ @ RestController
16+ @ RequestMapping ("/api/v1" )
17+ public class ApiOverviewController {
18+
19+ @ GetMapping ("/" )
20+ public ResponseEntity <Map <String , Object >> getApiOverview () {
21+ // Using LinkedHashMap to preserve the insertion order for a clean JSON output
22+ Map <String , Object > overview = new LinkedHashMap <>();
23+
24+ overview .put ("apiOverview" ,
25+ "Welcome to leetcode-stats-api! This is a custom API wrapper for LeetCode data, providing stable, well-documented endpoints." );
26+
27+ overview .put ("apiDocumentationLink" ,
28+ "https://github.com/rajat069/leetcode-stats-api/blob/main/README.md" );
29+
30+ Map <String , Object > routes = new LinkedHashMap <>();
31+
32+ Map <String , Object > userDetails = new LinkedHashMap <>();
33+ userDetails .put ("description" , "Endpoints for retrieving detailed user profile information." );
34+ userDetails .put ("Method" , "GET" );
35+
36+ Map <String , String > userPaths = new LinkedHashMap <>();
37+ userPaths .put ("/users/{username}/profile" , "Get question progress (accepted, failed, untouched)." );
38+ userPaths .put ("/users/{username}/languageStats" , "Get stats on languages used and problems solved per language." );
39+ userPaths .put ("/users/{username}/publicInfo" , "Get public profile info (avatar, ranking, social links)." );
40+ userPaths .put ("/users/{username}/badges" , "Get a list of badges earned by the user." );
41+ userPaths .put ("/users/{username}/userSkillStats" , "Get advanced, intermediate, and fundamental skill stats." );
42+ userPaths .put ("/users/{username}/recentUserSubmissions/{limit}" , "Get the {limit} most recent AC submissions." );
43+ userPaths .put ("/users/{username}/userCalendarStats/{year}" , "Get submission calendar, streak, and active days for a given {year}." );
44+
45+ userDetails .put ("endpoints" , userPaths );
46+ routes .put ("userDetails" , userDetails );
47+
48+ Map <String , Object > userContests = new LinkedHashMap <>();
49+ userContests .put ("description" , "Endpoints for retrieving user contest history and rankings." );
50+ userContests .put ("Method" , "GET" );
51+
52+ Map <String , String > contestPaths = new LinkedHashMap <>();
53+ contestPaths .put ("/users/{username}/contests/" , "Get user contest ranking and full contest history." );
54+ contestPaths .put ("/users/{username}/contests/ranking" , "Get just the user's contest ranking details." );
55+ contestPaths .put ("/users/{username}/contests/bestRanking" , "Get the user's single best-ranking contest performance." );
56+ contestPaths .put ("/users/{username}/contests/rankingHistory" , "Get the user's entire contest history." );
57+ contestPaths .put ("/users/{username}/contests/contest-name/{contestTitle}" , "Find contest history by matching part of a {contestTitle}." );
58+ contestPaths .put ("/users/{username}/contests/hasAttended/{attended}" , "Filter history by attendance (true or false)." );
59+ contestPaths .put ("/users/{username}/contests/trendDirection/{direction}" , "Filter history by rating trend (UP, DOWN, NONE)." );
60+ contestPaths .put ("/users/{username}/contests/problemSolvedGTE/{count}" , "Filter history for contests where problems solved were >= {count}." );
61+ contestPaths .put ("/users/{username}/contests/finishTime/{timeInSeconds}" , "Filter history for contests finished in less than {timeInSeconds}." );
62+ contestPaths .put ("/users/{username}/contests/biggestJumpInRating" , "Get the contest with the user's biggest rating increase." );
63+
64+ userContests .put ("endpoints" , contestPaths );
65+ routes .put ("userContests" , userContests );
66+
67+ Map <String , Object > questions = new LinkedHashMap <>();
68+ questions .put ("description" , "Endpoints for fetching and searching questions from the local database." );
69+
70+ Map <String , String > questionPaths = new LinkedHashMap <>();
71+ questionPaths .put ("/questions/ (GET)" , "Get a paginated list of all questions. Supports ?page=, &size=, &sort=." );
72+ questionPaths .put ("/questions/potd (GET)" , "Get the current LeetCode Problem of the Day (POTD)." );
73+ questionPaths .put ("/questions/search (POST)" , "A powerful search endpoint to filter questions. See README for request body." );
74+
75+ questions .put ("endpoints" , questionPaths );
76+ routes .put ("questions" , questions );
77+
78+
79+ Map <String , Object > globalContests = new LinkedHashMap <>();
80+ globalContests .put ("description" , "Endpoints for retrieving global contest data." );
81+ globalContests .put ("Method" , "GET" );
82+
83+ Map <String , String > globalContestPaths = new LinkedHashMap <>();
84+ globalContestPaths .put ("/globalContestInfo/fetchContests" , "Get a paginated list of all global contests from the local database." );
85+
86+ globalContests .put ("endpoints" , globalContestPaths );
87+ routes .put ("globalContests" , globalContests );
88+
89+ overview .put ("routes" , routes );
90+
91+ return ResponseEntity .ok (overview );
92+ }
93+ }
0 commit comments