Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 166d206

Browse files
Update Readme.md
1 parent 1e2453b commit 166d206

File tree

1 file changed

+82
-52
lines changed

1 file changed

+82
-52
lines changed

‎Readme.md

Lines changed: 82 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,74 @@
1-
# leetcode_api
2-
**How it works:**<br>
3-
LeetCode provides graphql query api. This is public api. But querying graphql little bit messy. So I have created this to easily get desired data.
4-
Leet code graphql URL = https://leetcode.com/graphql
5-
<br>Query used in this project is:
6-
```
7-
query getUserProfile($username: String!) {
8-
allQuestionsCount {
9-
difficulty
10-
count
11-
}
12-
matchedUser(username: $username) {
13-
contributions {
14-
points
15-
}
16-
profile {
17-
reputation
18-
ranking
19-
}
20-
submissionCalendar
21-
submitStats {
22-
acSubmissionNum {
23-
difficulty
24-
count
25-
submissions
26-
}
27-
totalSubmissionNum {
28-
difficulty
29-
count
30-
submissions
31-
}
32-
}
33-
}
34-
}
35-
```
36-
Check the `leetcode.js` file to see how the data was fetched by fetch api.
1+
# LeetCode API
372

38-
**By the way**
3+
## Overview
394

40-
**API URL** = [https://faisal-leetcode-api.cyclic.app/yourLeetcodeUsername](https://leetcode-api-faisalshohag.vercel.app/) <br>
41-
Response is like this:
42-
```
5+
This project provides a working Node.js API to interact with LeetCode's public GraphQL API, focusing on fetching submission calendars and other user statistics. The API simplifies querying LeetCode's data by providing structured endpoints.
6+
7+
## Features
8+
9+
- Fetch user profile information from LeetCode
10+
- Retrieve submission statistics and calendar data
11+
- Simplified GraphQL querying through a RESTful API
12+
13+
## Technologies Used
14+
15+
- **Node.js**
16+
- **Express.js**
17+
- **GraphQL**
18+
- **Fetch API**
19+
20+
## Installation
21+
22+
1. Clone the repository:
23+
```bash
24+
git clone https://github.com/faisal-shohag/leetcode_api.git
25+
```
26+
2. Navigate to the project directory:
27+
```bash
28+
cd leetcode_api
29+
```
30+
3. Install the dependencies:
31+
```bash
32+
npm install
33+
```
34+
35+
## Usage
36+
37+
1. Start the server:
38+
```bash
39+
node index.js
40+
```
41+
2. Access the API at `http://localhost:3000/yourLeetcodeUsername`
42+
43+
## API Endpoint
44+
45+
- **GET /:username** - Fetches the LeetCode profile and submission data for the specified username.
46+
47+
### Example Response
48+
49+
```json
4350
{
4451
"totalSolved": 43,
4552
"totalSubmissions": [
4653
{
47-
"difficulty": "All",
48-
"count": 58,
49-
"submissions": 116
54+
"difficulty": "All",
55+
"count": 58,
56+
"submissions": 116
5057
},
5158
{
52-
"difficulty": "Easy",
53-
"count": 15,
54-
"submissions": 34
59+
"difficulty": "Easy",
60+
"count": 15,
61+
"submissions": 34
5562
},
5663
{
57-
"difficulty": "Medium",
58-
"count": 33,
59-
"submissions": 54
64+
"difficulty": "Medium",
65+
"count": 33,
66+
"submissions": 54
6067
},
6168
{
62-
"difficulty": "Hard",
63-
"count": 10,
64-
"submissions": 27
69+
"difficulty": "Hard",
70+
"count": 10,
71+
"submissions": 27
6572
}
6673
],
6774
"totalQuestions": 2738,
@@ -84,3 +91,26 @@ Response is like this:
8491
}
8592
}
8693
```
94+
## Project Structure
95+
- `index.js` -Main server file that sets up the Express server and API routes.
96+
- `leetcode.js` -Contains the logic for interacting with LeetCode's GraphQL API.
97+
- `package.json` - Project metadata and dependencies.
98+
99+
## Demo
100+
101+
You can view a live demo of the project [here](https://leetcode-api-faisalshohag.vercel.app/). *(Please note that it may take a few seconds for the server to wake up.)*
102+
103+
## Contributing
104+
105+
Contributions are welcome! Please feel free to submit a pull request or open an issue to discuss improvements or bugs.
106+
107+
## License
108+
109+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
110+
111+
## Contact
112+
113+
- **Author:** Faisal Shohag
114+
- **Email:** faisalshohagprog@gmail.com
115+
- **LinkedIn:** [faisal-shohag](http://linkedin.com/in/faisal-shohag)
116+
- **GitHub:** [faisal-shohag](http://github.com/faisal-shohag)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /