Unlock LeetCode insights with an interactive API explorer. Get code snippets, test GraphQL endpoints, and view real-time data
All API requests are proxied through a secure
endpoint to https://leetcode.com/graphql/
.
Find your username at leetcode.com/u/your-username/
.
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);
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);
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);
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);
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);
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);
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);
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);
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);
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);