Skip to content

Commit bdf2855

Browse files
committed
add README.md
1 parent 0a778d3 commit bdf2855

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<h1 align="center">leetstats-api</h1>
2+
3+
<p align="center">
4+
<strong>The API for retrieving your LeetCode profile & Problems statistics</strong>
5+
</p>
6+
7+
<p align="center">
8+
<img src="https://img.shields.io/badge/License-MIT-green.svg"/>
9+
<img src="https://img.shields.io/badge/Maven-3.9.11-blue.svg?logo=apachemaven"/>
10+
</p>
11+
12+
<p align="center">
13+
<img src="https://img.shields.io/badge/Java-17-%2320232a.svg?style=for-the-badge&logo=openjdk&logoColor=white"/>
14+
<img src="https://img.shields.io/badge/Spring%20Boot-3.5.6-%2320232a?style=for-the-badge&logo=springboot&logoColor=6DB33F"/>
15+
<img src="https://img.shields.io/badge/Hibernate-6.5.2-%252320232a.svg?style=for-the-badge&logo=hibernate&logoColor=59666C"/>
16+
<img src="https://img.shields.io/badge/RestApi-%2320232a.svg?style=for-the-badge&logo=restAPI&logoColor=%23F7DF1E"/>
17+
</p>
18+
19+
## About This Project
20+
21+
I started this project after struggling to find clear, comprehensive documentation for the leetcode.com/graphql endpoint. To fill this gap for other developers, I decided to build the solution I was looking for.
22+
23+
**leetstats-api** is that solution: a custom API wrapper designed to provide stable, well-documented, and easy-to-use endpoints for LeetCode data.
24+
25+
It provides simple access to:
26+
27+
- **User Info**: Profile, Badges, Submissions, Language Stats, Skill Stats
28+
- **Contest Data**: History, Details, Rankings, and granular filtering
29+
- **Problem Data**: Paginated and searchable list of all questions
30+
31+
## API URL 🌐
32+
33+
The API base path is `/api/v1`. When run locally, it will be available at:
34+
35+
```
36+
http://localhost:8080/api/v1
37+
```
38+
39+
## Run with Maven 🔧
40+
41+
```bash
42+
./mvnw spring-boot:run
43+
```
44+
45+
## Endpoints 🚀
46+
47+
All endpoints are relative to the base path `/api/v1`.
48+
49+
### 👤 User Endpoints
50+
51+
**Base Path**: `/api/v1/users/{username}`
52+
53+
| Method | Endpoint | Description |
54+
|--------|----------|-------------|
55+
| GET | `/profile` | Get a user's question progress (accepted, failed, untouched). |
56+
| GET | `/languageStats` | Get stats on languages used and problems solved per language. |
57+
| GET | `/publicInfo` | Get a user's public profile info (name, avatar, ranking, social links). |
58+
| GET | `/badges` | Get a list of badges earned by the user. |
59+
| GET | `/userSkillStats` | Get advanced, intermediate, and fundamental skill stats. |
60+
| GET | `/recentUserSubmissions/{limit}` | Get the {limit} most recent AC submissions for a user. |
61+
| GET | `/userCalendarStats/{year}` | Get a user's submission calendar, streak, and active days for a given {year}. |
62+
63+
### 🏆 User Contest Endpoints
64+
65+
**Base Path**: `/api/v1/users/{username}/contests`
66+
67+
| Method | Endpoint | Description |
68+
|--------|----------|-------------|
69+
| GET | `/` | Get user contest ranking and full contest history in one call. |
70+
| GET | `/ranking` | Get just the user's contest ranking details (rating, global rank, etc.). |
71+
| GET | `/bestRanking` | Get the user's single best-ranking contest performance. |
72+
| GET | `/rankingHistory` | Get the user's entire contest history. |
73+
| GET | `/contest-name/{contestTitle}` | Find contest history by matching part of a {contestTitle}. |
74+
| GET | `/hasAttended/{attended}` | Filter history by attendance (true or false). |
75+
| GET | `/trendDirection/{direction}` | Filter history by rating trend (UP, DOWN, NONE). |
76+
| GET | `/problemSolvedGTE/{count}` | Filter history for contests where problems solved were >= {count}. |
77+
| GET | `/problemSolvedLTE/{count}` | Filter history for contests where problems solved were <= {count}. |
78+
| GET | `/finishTime/{timeInSeconds}` | Filter history for contests finished in less than {timeInSeconds}. |
79+
| GET | `/biggestJumpInRating` | Get the contest that resulted in the user's biggest rating increase. |
80+
| DELETE | `/evictUserData` | (Requires API Key) Evicts a user's contest data from the cache and DB. |
81+
82+
### ❓ Questions Endpoints
83+
84+
**Base Path**: `/api/v1/questions`
85+
86+
| Method | Endpoint | Description |
87+
|--------|----------|-------------|
88+
| GET | `/` | Get a paginated list of all questions from the local database. Supports `?page=`, `&size=`, and `&sort=`. |
89+
| POST | `/search` | A powerful search endpoint. See request body details below. |
90+
91+
#### POST /search Request Body
92+
93+
This endpoint allows for complex filtering and sorting of questions stored in the API's database.
94+
95+
**Example Request Body**:
96+
97+
```json
98+
{
99+
"skip": 0,
100+
"limit": 20,
101+
"searchKeyword": "two sum",
102+
"sortBy": {
103+
"sortField": "AC_RATE",
104+
"sortOrder": "DESCENDING"
105+
},
106+
"filters": {
107+
"filterCombineType": "ALL",
108+
"difficultyFilter": {
109+
"difficulties": ["EASY", "MEDIUM"],
110+
"operator": "IS"
111+
},
112+
"topicFilter": {
113+
"topicSlugs": ["array", "hash-table"],
114+
"operator": "IS"
115+
},
116+
"acceptanceFilter": {
117+
"rangeLeft": 30.0,
118+
"rangeRight": 70.0
119+
}
120+
}
121+
}
122+
```

0 commit comments

Comments
 (0)