Skip to content

A high-performance, resilient Spring Boot API wrapper that provides clean RESTful endpoints for LeetCode's GraphQL data, featuring built-in caching, rate limiting, persistent database

Notifications You must be signed in to change notification settings

Rajat069/leetstats-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 

Run with Maven 🔧

./mvnw spring-boot:run

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, resilient Spring Boot API wrapper that provides clean RESTful endpoints for LeetCode's GraphQL data, featuring built-in caching, rate limiting, persistent database

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages