LeetFetch

Unlock LeetCode insights with an interactive API explorer. Get code snippets, test GraphQL endpoints, and view real-time data

Interactive TestingMulti-Language SnippetsGraphQL API

All API requests are proxied through a secure endpoint to https://leetcode.com/graphql/.

Test Configuration
Enter a LeetCode username to test the API endpoints.
10 Endpoints Available

Find your username at leetcode.com/u/your-username/.

Category Filters

User Profile Information
Fetches basic user profile data, including contest badges, social media links, personal details, and activity counts.
Category: ProfileOperation: userPublicProfile
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query userPublicProfile($username: String!) {\n  matchedUser(username: $username) {\n    contestBadge { name expired hoverText icon }\n    username\n    githubUrl\n    twitterUrl\n    linkedinUrl\n    profile {\n      ranking userAvatar realName aboutMe school websites countryName\n      company jobTitle skillTags postViewCount postViewCountDiff\n      reputation reputationDiff solutionCount solutionCountDiff\n      categoryDiscussCount categoryDiscussCountDiff certificationLevel\n    }\n  }\n}",
9  "variables": {
10    "username": ""
11  },
12  "operationName": "userPublicProfile"
13})
14});
15
16const data = await response.json();
17console.log(data);
Programming Language Statistics
Retrieves problems solved broken down by programming language.
Category: StatisticsOperation: languageStats
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query languageStats($username: String!) {\n  matchedUser(username: $username) {\n    languageProblemCount { languageName problemsSolved }\n  }\n}",
9  "variables": {
10    "username": ""
11  },
12  "operationName": "languageStats"
13})
14});
15
16const data = await response.json();
17console.log(data);
Problem-Solving Skills Statistics
Provides problems solved categorized by skill areas (advanced, intermediate, fundamental).
Category: StatisticsOperation: skillStats
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query skillStats($username: String!) {\n  matchedUser(username: $username) {\n    tagProblemCounts {\n      advanced { tagName tagSlug problemsSolved }\n      intermediate { tagName tagSlug problemsSolved }\n      fundamental { tagName tagSlug problemsSolved }\n    }\n  }\n}",
9  "variables": {
10    "username": ""
11  },
12  "operationName": "skillStats"
13})
14});
15
16const data = await response.json();
17console.log(data);
Contest History and Rankings
Gathers a user's contest participation history and ranking details.
Category: ContestOperation: userContestRankingInfo
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query userContestRankingInfo($username: String!) {\n  userContestRanking(username: $username) {\n    attendedContestsCount rating globalRanking totalParticipants\n    topPercentage badge { name }\n  }\n  userContestRankingHistory(username: $username) {\n    attended trendDirection problemsSolved totalProblems\n    finishTimeInSeconds rating ranking\n    contest { title startTime }\n  }\n}",
9  "variables": {
10    "username": ""
11  },
12  "operationName": "userContestRankingInfo"
13})
14});
15
16const data = await response.json();
17console.log(data);
Problem Progress by Difficulty
Offers a detailed breakdown of a user's problem progress by difficulty level (Easy, Medium, Hard).
Category: ProgressOperation: userProfileUserQuestionProgress
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query userProfileUserQuestionProgress($userSlug: String!) {\n  userProfileUserQuestionProgress(userSlug: $userSlug) {\n    numAcceptedQuestions { difficulty count }\n    numFailedQuestions { difficulty count }\n    numUntouchedQuestions { difficulty count }\n  }\n}",
9  "variables": {
10    "userSlug": ""
11  },
12  "operationName": "userProfileUserQuestionProgress"
13})
14});
15
16const data = await response.json();
17console.log(data);
Overall Submission Statistics
Provides overall submission statistics and problem counts by difficulty.
Category: StatisticsOperation: userProblemsSolved
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query userProblemsSolved($username: String!) {\n  allQuestionsCount { difficulty count }\n  matchedUser(username: $username) {\n    submitStats {\n      acSubmissionNum { difficulty count submissions }\n      totalSubmissionNum { difficulty count submissions }\n    }\n  }\n}",
9  "variables": {
10    "username": ""
11  },
12  "operationName": "userProblemsSolved"
13})
14});
15
16const data = await response.json();
17console.log(data);
User Submission Calendar
Fetches a user's activity calendar, including active years, streaks, total active days, and submission counts.
Category: ActivityOperation: userProfileCalendar
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query userProfileCalendar($username: String!) {\n  matchedUser(username: $username) {\n    userCalendar {\n      activeYears\n      streak\n      totalActiveDays\n      submissionCalendar\n    }\n  }\n}",
9  "variables": {
10    "username": ""
11  },
12  "operationName": "userProfileCalendar"
13})
14});
15
16const data = await response.json();
17console.log(data);
Recent Accepted Submissions
Lists a specified number of a user's most recently accepted (solved) problems.
Category: ActivityOperation: recentAcSubmissions
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query recentAcSubmissions($username: String!, $limit: Int!) {\n  recentAcSubmissionList(username: $username, limit: $limit) {\n    id title titleSlug timestamp\n  }\n}",
9  "variables": {
10    "username": "",
11    "limit": 20
12  },
13  "operationName": "recentAcSubmissions"
14})
15});
16
17const data = await response.json();
18console.log(data);
Daily Coding Challenge Information
Retrieves comprehensive details about the current day's Daily Coding Challenge question.
Category: ChallengeOperation: questionOfToday
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query questionOfToday {\n  activeDailyCodingChallengeQuestion {\n    date\n    link\n    question {\n      titleSlug\n      title\n      difficulty\n      frontendQuestionId: questionFrontendId\n      status\n      topicTags { name id slug }\n    }\n  }\n}",
9  "variables": {},
10  "operationName": "questionOfToday"
11})
12});
13
14const data = await response.json();
15console.log(data);
Upcoming Contests
Retrieves information about all upcoming contests.
Category: ContestOperation: getContests
1// TypeScript/JavaScript
2const response = await fetch('/api/leetcode', {
3  method: 'POST',
4  headers: {
5    'Content-Type': 'application/json',
6  },
7  body: JSON.stringify({
8  "query": "query getContests {\n  allContests {\n    title\n    titleSlug\n    startTime\n    duration\n    isVirtual\n  }\n}",
9  "variables": {},
10  "operationName": "getContests"
11})
12});
13
14const data = await response.json();
15console.log(data);