LeetCode APIleetcode.com ↗
Search LeetCode problems by difficulty, tags, and category. List all programming contests and fetch public user profiles with submission stats via 3 endpoints.
What is the LeetCode API?
This API exposes 3 endpoints covering LeetCode's problem bank, contest schedule, and public user profiles. Use search_problems to filter the full problem set by difficulty, topic tags like dynamic-programming or hash-table, and category slugs such as algorithms or database. The response includes each problem's acceptance rate, paidOnly flag, topic tags, and frontend question ID — enough to build a problem-picker, study tracker, or contest-prep tool.
curl -X GET 'https://api.parse.bot/scraper/e4e91877-8a33-4462-b5ed-1a5cd60da1f0/search_problems?skip=0&tags=array&limit=5&keyword=two+sum&category=algorithms&difficulty=EASY' \ -H 'X-API-Key: $PARSE_API_KEY'
Typed, relational, agent-ready
A generated client with real types, enums, and the links between objects — the structure a flat JSON response can't carry. Autocompletes in your editor and reads cleanly to coding agents.
- Fully typed · autocompletes
- Objects link to objects
- Typed errors & pagination
Typed Python client. Set up the SDK in your uv project, then pull this API’s typed client:
uv add parse-sdk uv run parse init uv run parse add --marketplace leetcode-com-api
uv run parse add --marketplace pulls a pinned snapshot of this canonical API — it won’t change underneath you. To customize it, subscribe and swap to your own copy.
"""
LeetCode API — search problems, list contests, look up user profiles.
"""
from parse_apis.leetcode_api import LeetCode, Problem, Contest, UserProfile, Difficulty
leetcode = LeetCode()
# Search for easy array problems
for problem in leetcode.problems.search(keyword="two sum", difficulty=Difficulty.EASY):
print(problem.title, problem.ac_rate, problem.difficulty, problem.title_slug)
for tag in problem.topic_tags:
print(" tag:", tag.name, tag.slug)
# List all contests
for contest in leetcode.contests.list(limit=5):
print(contest.title, contest.start_time, contest.duration, contest.contains_premium)
# Fetch a user profile by username
user = leetcode.userprofiles.get(username="neal_wu")
print(user.username, user.profile.ranking, user.profile.country_name)
for stat in user.submit_stats_global.ac_submission_num:
print(stat.difficulty, stat.count, stat.submissions)
Search and filter LeetCode problems. Supports keyword search, difficulty filtering, topic tag filtering, category filtering, and offset-based pagination. Returns problems sorted by question number. Each problem includes acceptance rate, difficulty, question ID, paid-only status, title, slug, and topic tags.
| Param | Type | Description |
|---|---|---|
| skip | integer | Number of problems to skip for pagination (offset). |
| tags | string | Comma-separated topic tag slugs to filter by (e.g. 'array,hash-table,dynamic-programming'). |
| limit | integer | Maximum number of problems to return per page. |
| keyword | string | Search keyword to filter problems by title (e.g. 'two sum', 'binary tree'). |
| category | string | Category slug filter. Accepts: algorithms, database, shell, concurrency. Empty string returns all categories. |
| difficulty | string | Difficulty filter. Accepts exactly one of: EASY, MEDIUM, HARD. Case-insensitive input is uppercased internally. |
{
"type": "object",
"fields": {
"total": "integer - total number of problems matching the filters",
"questions": "array of Problem objects with acRate, difficulty, frontendQuestionId, paidOnly, title, titleSlug, topicTags"
},
"sample": {
"data": {
"total": 410,
"questions": [
{
"title": "Two Sum",
"acRate": 57.6,
"paidOnly": false,
"titleSlug": "two-sum",
"topicTags": [
{
"name": "Array",
"slug": "array"
},
{
"name": "Hash Table",
"slug": "hash-table"
}
],
"difficulty": "Easy",
"frontendQuestionId": "1"
}
]
},
"status": "success"
}
}About the LeetCode API
Problem Search
The search_problems endpoint accepts up to six filter parameters: keyword (title substring match), difficulty (EASY, MEDIUM, or HARD), tags (comma-separated tag slugs, e.g. array,binary-search), category (one of algorithms, database, shell, concurrency), and skip/limit for offset-based pagination. The response includes a total count of matching problems alongside a questions array. Each question object carries frontendQuestionId, title, titleSlug, difficulty, acRate (acceptance rate as a float), paidOnly (boolean), and a topicTags array with tag names and slugs.
Contests
list_contests returns the complete history of LeetCode weekly and biweekly contests — no filters, no pagination. Every contest object includes title, titleSlug, startTime (Unix timestamp), duration in seconds, originStartTime, and a containsPremium flag. The full list is returned in a single response sorted most-recent first, making it straightforward to identify upcoming or recently completed rounds.
User Profiles
get_user_profile takes a single required username parameter and returns public profile data. The profile object contains realName, aboutMe, userAvatar, reputation, ranking, company, school, websites, countryName, and skillTags. Submission statistics live in submitStatsGlobal, which holds an acSubmissionNum array broken out by difficulty level. If the username does not exist, the endpoint returns a stale_input response with kind input_not_found rather than an HTTP error.
The LeetCode API is a managed, monitored endpoint for leetcode.com — not a raw scraper you maintain. Every endpoint is automatically health-checked on a schedule, and when leetcode.com changes and a check fails, the API is automatically queued for repair and re-verified. It is built to keep working as the site underneath it changes.
This isn't an official leetcode.com API — it's an independent, maintained REST wrapper over public data. Where the source has no official API (or only a limited one), Parse gives you a stable contract over a source that never promised one, and keeps it current. Need a new endpoint or field? You can revise it yourself in plain English and the agent rebuilds it against the live site in minutes — contributing the change back to the shared API is free.
Will this API break when the source site changes?+
Is this an official API from the source site?+
Can I fix or extend this API myself if I need a new endpoint or field?+
What happens if I call an endpoint that has an issue?+
- Build a spaced-repetition study tool that surfaces unsolved MEDIUM and HARD problems filtered by a specific topic tag like
graphortree. - Generate a contest calendar by pulling
startTimeanddurationfromlist_contestsand syncing entries to a personal calendar. - Rank candidates in a hiring pipeline by comparing
rankingand per-difficultyacSubmissionNumvalues from their LeetCode profiles. - Track a user's global ranking over time by periodically polling
get_user_profileand storing therankingfield. - Filter premium-only problems using the
paidOnlyfield fromsearch_problemsto show only freely accessible content. - Identify problems with low acceptance rates by sorting results from
search_problemson theacRatefield for advanced challenge sets. - Display a contributor's
skillTags,company, andschoolon a developer portfolio page using data fromget_user_profile.
| Tier | Price | Credits/month | Rate limit |
|---|---|---|---|
| Free | $0/mo | 100 | 5 req/min |
| Hobby | $30/mo | 1,000 | 20 req/min |
| Developer | $100/mo | 5,000 | 100 req/min |
One credit = one API call regardless of which marketplace API you call. Exceeding the rate limit returns a 429 response. Authenticate with the X-API-Key header.
Does LeetCode have an official developer API?+
What does the `search_problems` endpoint return for problems that require a paid subscription?+
paidOnly boolean. When paidOnly is true, the problem is only accessible to LeetCode Premium subscribers. The endpoint returns the metadata — title, difficulty, tags, acceptance rate — for both free and premium problems, so you can filter or label them as needed.Does `list_contests` support filtering by contest type (weekly vs. biweekly) or by date range?+
title or titleSlug fields client-side. If you need server-side filtering or date-range slicing, you can fork the API on Parse and revise it to add those parameters.Does the API return a user's full submission history or individual solution code?+
get_user_profile returns aggregate accepted submission counts broken down by difficulty via submitStatsGlobal.acSubmissionNum. Individual submission records, solution code, and problem-by-problem solve history are not exposed. You can fork the API on Parse and revise it to add an endpoint covering submission details if that data becomes accessible.How should I handle a username that doesn't exist when calling `get_user_profile`?+
stale_input response with kind: input_not_found rather than an HTTP 404. Your client code should check for this response shape rather than relying solely on HTTP status codes to detect missing usernames.