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

A high-performance Spring Boot API wrapper for LeetCode, providing cached endpoints for user profiles, contest history, and a searchable question database. Features built-in rate limiting and a local SQLite DB for high availability.

Notifications You must be signed in to change notification settings

Rajat069/leetcode-stats-api

Repository files navigation

leetstats-api

The API for retrieving your LeetCode profile & Problems statistics

About This Project

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.

leetstats-api is that solution: a custom API wrapper designed to provide stable, well-documented, and easy-to-use endpoints for LeetCode data.

It provides simple access to:

  • User Info: Profile, Badges, Submissions, Language Stats, Skill Stats
  • Contest Data: History, Details, Rankings, and granular filtering
  • Problem Data: Paginated and searchable list of all questions

API URL 🌐

The API base path is /api/v1. When run locally, it will be available at:

http://localhost:8080/api/v1

Live:

https://4.213.1.116.nip.io/api/v1/

Run with Maven πŸ”§

./mvnw spring-boot:run

API Documentation πŸ“š

Interactive API documentation is available via Swagger UI:

Local:

http://localhost:8080/swagger-ui.html

Live:

https://4.213.1.116.nip.io/swagger-ui/swagger-ui/index.html

Endpoints πŸš€

All endpoints are relative to the base path /api/v1.

πŸ‘€ User Endpoints

Base Path: /api/v1/users/{username}

Method Endpoint Description
GET /profile Get a user's question progress (accepted, failed, untouched).
GET /languageStats Get stats on languages used and problems solved per language.
GET /publicInfo Get a user's public profile info (name, avatar, ranking, social links).
GET /badges Get a list of badges earned by the user.
GET /userSkillStats Get advanced, intermediate, and fundamental skill stats.
GET /recentUserSubmissions/{limit} Get the {limit} most recent AC submissions for a user.
GET /userCalendarStats/{year} Get a user's submission calendar, streak, and active days for a given {year}.

πŸ† User Contest Endpoints

Base Path: /api/v1/users/{username}/contests

Method Endpoint Description
GET / Get user contest ranking and full contest history in one call.
GET /ranking Get just the user's contest ranking details (rating, global rank, etc.).
GET /bestRanking Get the user's single best-ranking contest performance.
GET /rankingHistory Get the user's entire contest history.
GET /contest-name/{contestTitle} Find contest history by matching part of a {contestTitle}.
GET /hasAttended/{attended} Filter history by attendance (true or false).
GET /trendDirection/{direction} Filter history by rating trend (UP, DOWN, NONE).
GET /problemSolvedGTE/{count} Filter history for contests where problems solved were >= {count}.
GET /problemSolvedLTE/{count} Filter history for contests where problems solved were <= {count}.
GET /finishTime/{timeInSeconds} Filter history for contests finished in less than {timeInSeconds}.
GET /biggestJumpInRating Get the contest that resulted in the user's biggest rating increase.
DELETE /evictUserData (Requires API Key) Evicts a user's contest data from the cache and DB.

🌏 GlobalContests Endpoints

Base Path: /api/v1/globalContestInfo

Method Endpoint Description
GET /fetchContests Get a paginated list of all global contests from the local database. Supports ?page=, &size=, and &sort=.
GET /globalRanking Get a paginated list of global user rankings (PENDING)

❓ Questions Endpoints

Base Path: /api/v1/questions

Method Endpoint Description
GET / Get a paginated list of all questions from the local database. Supports ?page=, &size=, and &sort=.
GET /potd Get the current LeetCode Problem of the Day (POTD).
POST /search A powerful search endpoint. See request body details below.

POST /search Request Body

This endpoint allows for complex filtering and sorting of questions stored in the API's database.

Example Request Body:

{
 "skip": 0,
 "limit": 20,
 "searchKeyword": "two sum",
 "sortBy": {
 "sortField": "AC_RATE",
 "sortOrder": "DESCENDING"
 },
 "filters": {
 "filterCombineType": "ALL",
 "difficultyFilter": {
 "difficulties": ["EASY", "MEDIUM"],
 "operator": "IS"
 },
 "topicFilter": {
 "topicSlugs": ["array", "hash-table"],
 "operator": "IS"
 },
 "acceptanceFilter": {
 "rangeLeft": 30.0,
 "rangeRight": 70.0
 }
 }
}

About

A high-performance Spring Boot API wrapper for LeetCode, providing cached endpoints for user profiles, contest history, and a searchable question database. Features built-in rate limiting and a local SQLite DB for high availability.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /