LeetCode+API.SH

LeetCode API

LeetCode problems, daily challenges, contests, rankings, profiles and solution posts as clean JSON, with no GraphQL to reverse engineer.

The API.SH LeetCode API turns public LeetCode data into REST routes that return JSON. List problems with the problem-set filters (difficulty, topic tags, category, premium, sorted by acceptance rate or frequency), read one problem's metadata, fetch today's daily challenge, list topic tags and study plans such as Top Interview 150, and browse contests with their problems, full rankings and the global contest leaderboard. Pull a user's public profile, contest history and recent accepted submissions, and read the community solution posts for a problem with their full markdown. Problem data includes difficulty, acceptance rate, topic tags, similar problems, likes and the function signature. Profiles include solved counts, ranking, badges, streak, solved problems per language and topic, contest rating and a submission calendar.

  • 14 endpoints
  • from $1 / 1,000 calls
  • 1,000 free credits / month
  • failed calls free
LeetCode user profile
GET https://api.api.sh/leetcode/v1/user
{"username": "lee215","url": "https://leetcode.com/u/lee215/","real_name": "lee","avatar": "https://assets.leetcode.com/users/lee215/avatar_1551541889.png","about": "Lee codes for fun :)\n\n   🍠lee215: 2950607729","country": "China","company": null,"school": null,"websites": ["https://www.youtube.com/channel/UCUBt1TDQTl1atYsscVoUzoQ"],"skills": ["python","java","… 1 more"],"github": null,"twitter": null,"linkedin": null,"ranking": 102193,"reputation": 231393,"post_views": 20808041,"solutions": 1382,"discussions": 1,"solved": {"all": 695,"easy": 127,"medium": 416,"hard": 152},"problems_total": {"all": 4101,"easy": 975,"medium": 2139,"hard": 987},"streak": 3,"active_days": 48,"active_years": [2014,2016,"… 10 more"],"calendar_year": null,"submission_calendar": [{"date": "2025-11-08","submissions": 10},{"date": "2025-11-22","submissions": 1},"… 46 more"],"badges": [{"name": "Guardian","icon": "https://leetcode.com/static/images/badges/guardian.png","date": "2026-05-06"},{"name": "500 Days Badge","icon": "https://assets.leetcode.com/static_assets/marketing/lg500.png","date": "2024-12-08"},"… 1 more"],"active_badge": "365 Days Badge","languages": [{"language": "C++","problems_solved": 152},{"language": "Java","problems_solved": 245},"… 5 more"],"skills_advanced": [{"tag": "data-stream","problems_solved": 3},{"tag": "game-theory","problems_solved": 9},"… 16 more"],"skills_intermediate": [{"tag": "tree","problems_solved": 57},{"tag": "binary-tree","problems_solved": 54},"… 17 more"],"skills_fundamental": [{"tag": "array","problems_solved": 385},{"tag": "matrix","problems_solved": 48},"… 8 more"],"contest": {"rating": 2204,"attended": 27,"global_ranking": 7625,"total_participants": 890724,"top_percentage": 0.9,"badge": "Guardian"},"cached": false,"credits_used": 1}
1 credit · $1 per 1,000 calls

What you can build with the LeetCode API

Problem finders and study planners

Filter the problem set by difficulty, topic tags, category and acceptance rate, sort by frequency, or load a study plan's sections, to build practice lists by pattern.

Daily challenge bots

Post today's LeetCode daily problem with its difficulty and topic tags to a Discord, Slack, Todoist or email list.

Leaderboards and cohort tracking

Compare students, a bootcamp class or a friend group by solved counts, ranking, streak, active days and recent accepted submissions.

Contest tracking and rating charts

Keep a calendar of upcoming contests, read a contest's problems and points and its ranking with each contestant's solve times, chart a user's rating after each contest, and watch the global leaderboard.

Portfolio and profile widgets

Show solved counts by difficulty, badges, languages and the submission calendar on a personal site or resume page.

AI study agents and solution research

Give an assistant problem lookups, a user's progress and the most-voted community solutions in a language so it can suggest what to practice next.

LeetCode data you get

Field names from real responses. Numbers come parsed, URLs absolute, dates in ISO 8601.

LeetCode contest/leetcode/v1/contest
titleWeekly Contest 400slugweekly-contest-400urlhttps://leetcode.com/contest/wee…start2024-06-02T02:30:00.000Zduration_minutes90finishedtruevirtualfalsecontains_premiumfalsedescriptionWelcome to the 400th LeetCode We…
problems[]title · slug · url · points · internal_id
LeetCode contest ranking/leetcode/v1/contest/ranking
slugweekly-contest-400urlhttps://leetcode.com/contest/wee…participants35706all_solved2018page1count25next_page2
questions[]question_id · title · slug · points
items[]rank · username · user_slug · country · country_code · region · score · finish_time · avatar · profile_url · medal · problems
LeetCode contests/leetcode/v1/contests
total_past726page1count10next_page2
upcoming[]title · slug · url · start · duration_minutes · virtual
items[]title · slug · url · start · duration_minutes · virtual

LeetCode API endpoints and prices

Every LeetCode endpoint costs 1 credit per call: credits are $1 per 1,000 on a monthly plan, $2 pay-as-you-go. Pricing

Search and discovery1
LeetCode topic tags
/leetcode/v1/tags
params none requireddocstry
$1 · $2 PAYG
1 credit
Profiles and accounts3
LeetCode user profile
/leetcode/v1/user
params username +1 optionaldocstry
$1 · $2 PAYG
1 credit
LeetCode user contest history
/leetcode/v1/user/contests
params username +1 optionaldocstry
$1 · $2 PAYG
1 credit
LeetCode user recent accepted submissions
/leetcode/v1/user/submissions
params username +1 optionaldocstry
$1 · $2 PAYG
1 credit
Posts and media2
LeetCode problem solutions and discussion posts
/leetcode/v1/discuss
params slug +5 optionaldocstry
$1 · $2 PAYG
1 credit
LeetCode solution post
/leetcode/v1/discuss/post
params iddocstry
$1 · $2 PAYG
1 credit
More data8
LeetCode contest
/leetcode/v1/contest
params slugdocstry
$1 · $2 PAYG
1 credit
LeetCode contest ranking
/leetcode/v1/contest/ranking
params slug +1 optionaldocstry
$1 · $2 PAYG
1 credit
LeetCode contests
/leetcode/v1/contests
params none required +2 optionaldocstry
$1 · $2 PAYG
1 credit
LeetCode daily challenge
/leetcode/v1/daily
params none requireddocstry
$1 · $2 PAYG
1 credit
LeetCode global contest ranking
/leetcode/v1/global-ranking
params none required +1 optionaldocstry
$1 · $2 PAYG
1 credit
LeetCode problem
/leetcode/v1/problem
params slugdocstry
$1 · $2 PAYG
1 credit
LeetCode problem list
/leetcode/v1/problems
params none required +9 optionaldocstry
$1 · $2 PAYG
1 credit
LeetCode study plans
/leetcode/v1/study-plan
params none required +1 optionaldocstry
$1 · $2 PAYG
1 credit

Call the LeetCode API

LeetCode user profile: GET https://api.api.sh/leetcode/v1/user

curl "https://api.api.sh/leetcode/v1/user?username=lee215" \
  -H "x-api-key: $APISH_KEY"
  1. Create a free accountConfirm your email and get 1,000 free credits every month. No card needed.
  2. Create an API keyOne key works for all 921 platforms.
  3. Send the requestJSON back in one call. Add output=csv or output=ndjson for files.

Why API.SH for LeetCode data

  • Public data only: no LeetCode login, cookies or account needed
  • One key and one response shape for LeetCode and 920 other platforms
  • Built and maintained by API.SH, not third-party publishers
  • Pay per call; errors on our side cost nothing
  • No rate limits: run as many calls in parallel as you need
  • Live status for every endpoint

API.SH vs the official LeetCode API

We found no documented public LeetCode API in the search results: a LeetCode forum thread asks whether one exists, and developers usually wrap the site's internal GraphQL queries in community projects such as alfa-leetcode-api or python-leetcode, which can break when the site changes. API.SH gives you fixed REST routes and one JSON shape, and it does not return problem statements.

Instead of hosting a GitHub wrapper, keeping GraphQL queries up to date or paying per run for an Apify actor, use one API.SH key with a fixed price per call, routes that are kept working for you and GitHub on the same key.

LeetCode API questions

What LeetCode data can I get?+

Problem lists with filters (/leetcode/v1/problems), one problem's metadata (/leetcode/v1/problem), the daily challenge (/leetcode/v1/daily), topic tags (/leetcode/v1/tags), study plans (/leetcode/v1/study-plan), contests (/leetcode/v1/contests and /leetcode/v1/contest), contest rankings (/leetcode/v1/contest/ranking), the global ranking (/leetcode/v1/global-ranking), a user's public profile (/leetcode/v1/user), contest history (/leetcode/v1/user/contests), recent accepted submissions (/leetcode/v1/user/submissions) and community solution posts (/leetcode/v1/discuss and /leetcode/v1/discuss/post).

How much does the LeetCode API cost?+

Every LeetCode endpoint costs 1 credit per call. On a monthly plan 1,000 credits cost $1 (Starter is $50/month for 50,000 credits). Pay-as-you-go is $2 per 1,000 credits, with top-ups from $15 that never expire.

Is there a free trial?+

Yes. Every account gets 1,000 free credits every month. That is 1,000 calls to /leetcode/v1/contest at 1 credit each.

Is there an official LeetCode API?+

LeetCode does not document a public API that we could find. Most tools wrap its internal GraphQL queries. API.SH offers a stable alternative with REST routes, and it reads public pages only.

Do I need a LeetCode account or login?+

No. API.SH reads public LeetCode pages only. No endpoint uses a login, cookies or anyone's account. Premium-only content is not returned, though problems carry a premium flag.

Can I get the problem statement or solutions?+

Not the statement. The problem route returns metadata such as difficulty, tags, acceptance rate, hints count and function signature, but not the statement text or LeetCode's official solution. Community solution posts are available: /leetcode/v1/discuss lists them by hot, most votes or most recent, filtered by language tag, and /leetcode/v1/discuss/post returns one post's full markdown.

How do I get a user's LeetCode stats with Python?+

Call /leetcode/v1/user with username using requests or the Python SDK; the JSON has solved counts by difficulty, ranking, streak, badges and the submission calendar. JavaScript has an SDK too, and Google Sheets, Zapier, Make and n8n work without code.

How do I get started?+

1. Sign up at api.sh. 2. Copy your API key from the dashboard. 3. Call /leetcode/v1/problem with a slug such as two-sum, or /leetcode/v1/daily for today's challenge. Request examples and every parameter are in the docs at https://api.sh/docs. You can also use the JS or Python SDK, Google Sheets, Zapier, Make, n8n or the MCP server at https://api.sh/mcp.

Does the LeetCode API have a rate limit?+

No. API.SH puts no rate limit on your key: send as many LeetCode calls in parallel as you need and pay only for the calls that run. If LeetCode itself slows down, the call returns 503 with a retry-after header and is not charged.

More reference APIs all developer & reference APIs →

Start with 1,000 free credits
Every month, on every account. One key works for all 921 platforms.
Get a free API key