This API offers several endpoints for retrieving user details, contest information, discussions, and problem details from the LeetCode GraphQL API. As part of my iOS SwiftUI learning journey, I developed an app for LeetCode: LeetCode Profile Visualization. To support the app, I incorporated the following GraphQL queries. The original codebase for this API is derived from: https://github.com/alfaarghya/alfa-leetcode-api
- Added API cache
- Added Axios for rapid development
GET /:username
: Get your LeetCodeVis profile details.GET /:username/badges
: Get your badges.GET /:username/solved
: Get total number of questions you solved.GET /:username/contest
: Get your contest details.GET /:username/contest/history
: Get all contest history.GET /:username/submission
: Get your last 20 submissions.GET /:username/acSubmission
: Get your last 20 accepted submissions.GET /:username/calendar
: Get your submission calendar.GET /userProfile/:username
: Get full profile details in one call.GET /userProfileCalendar?username=yourname&year=2024
: Get your calendar details with year.GET /languageStats/:username
: Get your language stats.GET /userProfileUserQuestionProgressV2/:userSlug
: Get your question progress.GET /skillStats/:username
: Get your skill stats.
GET /contest/:contestSlug
: Get contest details.GET /contestRanking/:contestSlug
: Get contest ranking.GET /userContestRankingInfo/:username
: Get user contest ranking info.
GET /discussion/:first
: Get trending discussion.GET /discussTopic/:topicId
: Get discussion topic.GET /discussComments/:topicId
: Get discussion comments.
GET /select?titleSlug=two-sum
: Get selected problem.GET /daily
: Get daily problem.GET /dailyQeustion
: Get raw daily question.GET /questionOfTodayQuery
: Get raw question of today.GET /problems
: Get list of 20 problems.GET /problems?limit=50
: Get list of some problems.GET /problems?tags=array+math
: Get list problems on selected topics.GET /problems?tags=array+math+string&limit=5
: Get list some problems on selected topics.GET /officialSolution?titleSlug=two-sum
: Get official solution of selected problem.
Please note that all endpoints are subject to rate limiting and other restrictions.
At First, I struggled to find proper documentation for the leetcode.com/graphql
. After scouring various articles about the LeetCode public API, I still couldn't find the comprehensive documentation I was looking for. Fueled by the desire to fill this gap I created alfa-leetcode-api.
alfa-leetcode-api is a custom solution born out of the need for a well-documented and detailed LeetCode API. This project is designed to provide developers with endpoints that offer insights into a user's profile, badges, solved questions, contest details, contest history, submissions, and also daily questions, selected problem, list of problems.
https://alfa-leetcode-api.onrender.com/
I've implemented a rate limit to prevent any potential server overload issues.
During development, it's recommended to utilize the API locally. To do so, follow this documentation => Local Deploy
Details | Endpoint | Description | Demo |
---|---|---|---|
Profile | /:username |
Get details about a user's profile. | click here |
Badges | /:username/badges |
Get the badges earned by the user. | click here |
Solved | /:username/solved |
Get the total number of questions solved by the user. | click here |
Contest | /:username/contest |
Get details about the user's contest participation. | click here |
Contest History | /:username/contest/history |
Get contest history. | click here |
Submission | /:username/submission |
Get the last 20 submissions of the user. | click here |
Limited Submission | /:username/submission?limit=number |
Get a specified number of the user's last submissions. | click here |
Accepted Submission | /:username/acSubmission |
Get the last 20 accepted submission of the user. | click here |
Limited Accepted Submission | /:username/acSubmission?limit=7 |
Get a specified number of the user's last accepted submission. | click here |
Calendar | /:username/calendar |
Get the user's submission calendar. | click here |
Details | Endpoint | Description | Demo |
---|---|---|---|
Daily Problem | /daily |
Get the daily question. | click here |
Selected Problem | /select?titleSlug=selected-question |
Get details about a selected-question. | click here |
Problems | /problems |
Get a list of 20 problems. | click here |
Limited Problems | /problems?limit=number |
Get a list of a specified number of problems. | click here |
Filter Problems | /problems?tags=tag1+tag2 |
Get a list of problems based on selected tags. | click here |
Filter & Limited Problems | /problems?tags=tag1+tag2+tag3&limit=number |
Get a list of a specified number of problems based on selected tags. | click here |
Contributor | Contribution |
---|---|
@aryanpingle | AC submission |
@jamesh48 | TypeScript Refactoring |
@kvqn | PORT environment variable |