LeetCode Unified Scraper & Submitter
Pricing
from $1.00 / 1,000 completed leetcode operations
LeetCode Unified Scraper & Submitter
One actor for every legal LeetCode action — public profile/contest/problem/discussion scraping, authenticated submissions, run/poll results, and a raw GraphQL passthrough. All operations accept configurable random delays and an optional `simulateHuman` mode for anti-rate-limit politeness.
Pricing
from $1.00 / 1,000 completed leetcode operations
Rating
5.0
(1)
Developer
Subham Shah
Maintained by CommunityActor stats
0
Bookmarked
2
Total users
1
Monthly active users
2 days ago
Last modified
Categories
Share
LeetCode Scraper, Code Runner & Submitter API
Scrape LeetCode profiles, problems, contests, discussions, and daily challenges from one Apify Actor. With a user's own authenticated LeetCode session, run code against test cases, submit solutions, and retrieve personal submissions, favorites, and progress.
Built for developer tools, study dashboards, coding-workflow automations, and research. It returns normalized dataset records, supports advanced GraphQL queries, and includes configurable pacing, optional Apify Proxy support, and a per-run spending-cap guard.
Why use this Actor?
| Capability | What it provides |
|---|---|
| Public LeetCode data | Profiles, statistics, problems, official solutions, contests, rankings, discussions, and daily challenges |
| Authenticated account data | Personal submissions, accepted submissions, favorites, and progress using the caller's own session |
| Code runner | Runs a solution against test input and polls the LeetCode result |
| Code submitter | Submits a solution and returns the final LeetCode submission result |
| Advanced GraphQL | Sends an explicit query only to LeetCode's official GraphQL endpoint |
| Production controls | Pacing, jitter, stable per-run proxy support, structured outputs, and a spending-cap guard |
Start with a public use case
Run the public Daily Challenge directly:
apify call subham_shah/leetcode-unified-scraper \--input='{ "operation": "dailyProblem", "simulateHuman": false }' \--output-dataset
| Use case | Example input |
|---|---|
| Today's Daily Challenge | examples/daily_challenge.json |
| Public profile and statistics | examples/profile_summary.json |
| Problem details and tags | examples/problem_details.json |
Key operations
Public reads - no LeetCode login required
- Profiles and stats:
userSummary,userProfile,userContest,userContestHistory,userBadges,userSkillStats,userLanguageStats,userCalendar,userHeatmap,userSubmissions,userAcSubmissions - Problems:
dailyProblem,dailyStreak,selectProblem,problemList,officialSolution - Contests:
allContests,upcomingContests,contestDetail,contestRanking - Discussions:
trendingDiscussions,discussTopic,discussComments - Advanced queries:
rawGraphql, restricted to LeetCode's official GraphQL host
Authenticated reads and writes - caller provides their own session
- Personal data:
mySubmissions,myAcSubmissions,myFavorites,myProgress - Run code:
runCodesends code to LeetCode's test runner and polls the result - Submit code:
submitCodesubmits code to LeetCode and polls the final verdict
Authenticated operations require LEETCODE_SESSION and csrftoken secret inputs from the user's own logged-in LeetCode browser session. Do not put credentials in public tasks, datasets, README examples, or source control.
User's LeetCode session|vApify secret input (encrypted) ---> HTTPS request to LeetCode only|+-- never written to this Actor's dataset or logs
Example inputs
Get today's Daily Challenge
{"operation": "dailyProblem"}
Get a public profile summary
{"operation": "userSummary","username": "uwi"}
Browse medium array problems
{"operation": "problemList","difficulty": "MEDIUM","tags": "array","limit": 20,"offset": 0}
Run code against a problem - authentication required
{"operation": "runCode","titleSlug": "two-sum","lang": "python3","typedCode": "class Solution:\n def twoSum(self, nums, target):\n return []","dataInput": "[2,7,11,15]\n9","LEETCODE_SESSION": "<secret session cookie>","csrftoken": "<secret csrf token>"}
Submit code - authentication required
{"operation": "submitCode","titleSlug": "two-sum","lang": "python3","typedCode": "class Solution:\n def twoSum(self, nums, target):\n return []","LEETCODE_SESSION": "<secret session cookie>","csrftoken": "<secret csrf token>","pollTimeoutMs": 30000}
Raw GraphQL - advanced use
{"operation": "rawGraphql","rawOperationName": "QuestionTitle","rawQuery": "query QuestionTitle($titleSlug: String!) { question(titleSlug: $titleSlug) { questionId title titleSlug } }","customVariables": { "titleSlug": "two-sum" }}
Normalized output
Every run writes one normalized record to the default dataset. This makes result handling consistent even though different LeetCode operations return different data.
Daily Challenge result
{"operation": "dailyProblem","success": true,"timestamp": "2026-07-13T00:00:00.000+00:00","data": {"date": "2026-07-13","link": "/problems/sequential-digits/","question": {"frontendQuestionId": "1291","title": "Sequential Digits","titleSlug": "sequential-digits","difficulty": "Medium"}}}
Code-run result
{"operation": "runCode","success": true,"data": {"submission_id": "<redacted>","state": "SUCCESS","status_msg": "Accepted","lang": "python3","slug": "two-sum","result_url": "https://leetcode.com/submissions/detail/<redacted>/"}}
When an operation cannot complete, the record has success: false and an actionable error. Read-only public operations may attempt one safe frontend-data fallback after a GraphQL failure. Write operations and missing authentication are never masked by that fallback.
Input controls
| Operation group | Useful controls |
|---|---|
user* | username, year, limit |
dailyProblem / dailyStreak | username, year, timezone, includeDailyDetails |
selectProblem / officialSolution | titleSlug |
problemList | problemCategorySlug, difficulty, tags, searchQuery, skipPaidOnly, limit, offset |
| Contest operations | categorySlug, page, limit |
| Discussion operations | discussionCategories, first, topicId, page, limit, commentOrderBy |
| Personal submission operations | limit, offset, lastKey |
runCode | titleSlug, lang, typedCode, dataInput, pollTimeoutMs |
submitCode | titleSlug, lang, typedCode, pollTimeoutMs |
rawGraphql | rawQuery, rawOperationName, customVariables |
The Actor accepts one operation per run. Inputs unrelated to the selected operation are ignored, allowing integrations to reuse a single input object safely.
Calling from an AI agent
Agents connected to Apify MCP can discover this Actor by its LeetCode intent, inspect the input and output schemas, and call it with one operation at a time. Begin with a public operation such as dailyProblem, userSummary, or selectProblem; use authenticated operations only when the caller can supply its own secret session inputs.
For a direct integration, invoke subham_shah/leetcode-unified-scraper through the Apify API or client SDK with the same JSON used in the examples above. Read the normalized dataset record's success, error, requiresAuth, and warnings fields before chaining the result into another workflow.
Pricing
This Actor uses Apify's pay-per-event model plus the platform usage generated by a run. A completed operation that writes a result to the default dataset triggers the result event; starting a run triggers the Actor-start event. The Store Pricing tab is the authoritative source for the current prices and any run-cost limit.
What this doesn't do
- It does not solve LeetCode problems or generate an algorithm for you; provide your own code for
runCodeandsubmitCode. - It does not bypass paid content, browser challenges, account controls, or rate limits.
- It does not collect other users' private account data or store caller session cookies in datasets or logs.
- It does not turn raw GraphQL into arbitrary web requests; the request target is restricted to LeetCode's GraphQL endpoint.
For automated solution generation, use a coding model alongside this Actor. For general web-page crawling, use a web crawler; this Actor is focused on LeetCode data and LeetCode code-execution workflows.
Pacing, proxy, and reliability
simulateHuman: trueis the default and applies operation-aware delays.- Set
simulateHuman: falseto controlminDelayMs,maxDelayMs,thinkBeforeSubmitMs, andthinkAfterWrongMsyourself. jitter: trueadds random variance to configured delays.- For larger public reads, enable
proxyConfiguration.useApifyProxy. The Actor uses one stable proxy URL for the run, which avoids changing the IP of an authenticated session mid-operation. - The default configuration makes direct requests. A proxy can reduce IP-based rate-limit risk but cannot solve browser challenges or guarantee access.
- The Actor respects Apify's maximum run-charge limit before starting a request that cannot return a billable result.
Limitations and responsible use
- LeetCode can change its frontend, GraphQL schema, or rate limits without notice.
- A valid LeetCode session is required for personal data, code execution, and code submission.
- The Actor does not bypass paywalls, browser challenges, or access controls.
- Only submit code you are authorized to submit, and respect LeetCode's terms and rate limits.
rawGraphqlaccepts only the official LeetCode GraphQL endpoint, so user cookies cannot be forwarded to arbitrary hosts.
Local development and deployment
# Install dependencies and testpip install -e ".[dev]"python -m pytestapify validate-schema# Run the Daily Challenge locallyapify run --input='{"operation":"dailyProblem"}'# Build and deploydocker build -t leetcode-unified-scraper .apify push --wait-for-finish 600
Apify runs this project as a Dockerized Actor, so a separate VPS is not required. The included GitHub Actions workflows run tests and validate/build the Actor; the manual deployment workflow requires an APIFY_TOKEN repository secret.
Support
When reporting an issue, include the selected operation, non-secret input values, timestamp, and returned error. Never include LEETCODE_SESSION, csrftoken, API tokens, or request captures containing cookies.