Leetcode API avatar
Leetcode API

Pricing

from $0.02 / 1,000 results

Go to Apify Store
Leetcode API

Leetcode API

Scrape LeetCode user profiles, problems, contests, and discussions. Get user stats, solved problems, contest ratings, submission history, activity heatmaps, daily challenges, and more - all without authentication.

Pricing

from $0.02 / 1,000 results

Rating

5.0

(1)

Developer

Raghav Taneja

Raghav Taneja

Maintained by Community

Actor stats

0

Bookmarked

7

Total users

2

Monthly active users

a month ago

Last modified

Share

LeetCode API Scraper

Scrape LeetCode user profiles, problems, contests, and discussions data without authentication.

Features

  • User Data: Profiles, badges, solved problems, contest rankings, submission history, activity heatmaps
  • Problem Data: Daily challenges, specific problems, problem lists with filters, official solutions
  • Contest Data: All contests, upcoming contests, contest details, leaderboards
  • Discussion Data: Trending discussions, topic details, comments

Input

FieldTypeDescription
operationStringRequired. The type of data to fetch
usernameStringLeetCode username (for user operations)
titleSlugStringProblem/contest slug (e.g., "two-sum")
limitIntegerNumber of items to fetch (default: 20)
skipIntegerItems to skip for pagination
yearIntegerYear for calendar/heatmap data
difficultyStringFilter: EASY, MEDIUM, HARD
tagsStringComma-separated topic tags
topicIdIntegerDiscussion topic ID
pageIntegerPage number for rankings

Operations

User Operations

  • userProfile - Basic user profile
  • userSummary - Complete user data in one call (recommended)
  • userBadges - User badges
  • userSolved - Solved problems with percentages
  • userContest - Contest rating and stats
  • userContestHistory - Contest participation history
  • userSubmissions - Recent submissions (max 20)
  • userAcSubmissions - Recent accepted submissions (max 20)
  • userCalendar - Submission calendar
  • userHeatmap - Activity heatmap (year/month/day breakdown)
  • userSkillStats - Skill tags by category
  • userLanguageStats - Programming language stats

Problem Operations

  • dailyProblem - Today's daily challenge
  • selectProblem - Get specific problem by titleSlug
  • problemList - List problems with filters
  • officialSolution - Get official solution for a problem

Contest Operations

  • allContests - All LeetCode contests
  • upcomingContests - Upcoming contests with countdown
  • contestDetail - Specific contest details
  • contestRanking - Contest leaderboard

Discussion Operations

  • trendingDiscussions - Trending discussion topics
  • discussTopic - Get discussion topic details
  • discussComments - Get discussion comments

Example Usage

Get User Summary

{
"operation": "userSummary",
"username": "uwi"
}

Get Daily Problem

{
"operation": "dailyProblem"
}

Get Problem List with Filters

{
"operation": "problemList",
"difficulty": "MEDIUM",
"tags": "array,dynamic-programming",
"limit": 50
}

Get Contest Ranking

{
"operation": "contestRanking",
"titleSlug": "weekly-contest-350",
"page": 1
}

Output

Results are saved to the default dataset with this structure:

{
"operation": "userSummary",
"success": true,
"data": { /* LeetCode data */ },
"timestamp": "2024-01-15T10:30:00.000Z"
}

Limitations

  • Submission limit: LeetCode's public API limits userSubmissions and userAcSubmissions to 20 items. Use userSummary for aggregate stats.
  • Rate limiting: Implemented to avoid overloading LeetCode's servers
  • Premium content: Some content may require LeetCode Premium subscription

Notes

  • Problem content is cleaned and formatted from HTML to readable text
  • HTML entities (\u003C, <, etc.) are properly decoded
  • Solutions include video and code playground links
  • Heatmaps include daily submission counts organized by year/month/day

Cost

This Actor uses minimal compute resources as it only makes HTTP requests to LeetCode's GraphQL API.

Support

For issues and feature requests, please open an issue in the repository.