+LeetCode API
LeetCode problems, daily challenges, contests and public profiles as clean JSON, with no GraphQL to reverse engineer.
The API.SH LeetCode API turns public LeetCode data into structured JSON. List problems with the problem-set filters, read one problem's metadata, fetch today's daily challenge, browse contests and pull a user's public profile, contest history and recent accepted submissions. Problem data includes difficulty, acceptance rate, topic tags, similar problems and likes. Profiles include solved counts, ranking, badges, streak and a submission calendar.
- 8 endpoints
- from $1 / 1,000 calls
- 1,000 free credits / month
- failed calls free
GET https://api.api.sh/leetcode/v1/ user
{ "success": true } 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, then sort by frequency 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 or email list.
Leaderboards and cohort tracking
Compare students, a bootcamp class or a friend group by solved counts, ranking, streak and active days.
Contest tracking
Keep a calendar of upcoming contests, read a contest's problems and points, and chart a user's rating after each contest.
Portfolio and profile widgets
Show solved counts by difficulty, badges, languages and the submission calendar on a personal site or resume page.
LeetCode data you get
Field names from real responses. Numbers come parsed, URLs absolute, dates in ISO 8601.
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
| LeetCode user profile /leetcode/ | $1 · $2 PAYG 1 credit |
| LeetCode user contest history /leetcode/ | $1 · $2 PAYG 1 credit |
| LeetCode user recent accepted submissions /leetcode/ | $1 · $2 PAYG 1 credit |
| LeetCode contest /leetcode/ | $1 · $2 PAYG 1 credit |
| LeetCode contests /leetcode/ | $1 · $2 PAYG 1 credit |
| LeetCode daily challenge /leetcode/ | $1 · $2 PAYG 1 credit |
| LeetCode problem /leetcode/ | $1 · $2 PAYG 1 credit |
| LeetCode problem list /leetcode/ | $1 · $2 PAYG 1 credit |
Call the LeetCode API
LeetCode user profile: GET https://api.api.sh/leetcode/
curl "https://api.api.sh/leetcode/v1/user?username=lee215" \
-H "x-api-key: $APISH_KEY" import os, requests
res = requests.get(
"https://api.api.sh/leetcode/v1/user",
params={"username": "lee215"},
headers={"x-api-key": os.environ["APISH_KEY"]},
timeout=120,
)
res.raise_for_status()
data = res.json() const url = new URL("https://api.api.sh/leetcode/v1/user");
url.searchParams.set("username", "lee215");
const res = await fetch(url, { headers: { "x-api-key": process.env.APISH_KEY } });
if (!res.ok) throw new Error(`${res.status} ${await res.text()}`);
const data = await res.json(); # Google Sheets (API.SH add-on)
=APISH("/leetcode/v1/user", "username", "lee215")
# Zapier, Make, n8n (verified node): pick the API.SH app,
# choose "LeetCode" and "LeetCode user profile".
# AI agents (Claude, ChatGPT, Cursor): add the
# API.SH MCP server https://api.sh/mcp - Create a free accountConfirm your email and get 1,000 free credits every month. No card needed.
- Create an API keyOne key works for all 483 platforms.
- Send the requestJSON back in one call. Add
output=csvoroutput=ndjsonfor 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 482 other platforms
- Built and maintained by API.SH, not third-party publishers
- Pay per call; errors on our side cost nothing
- Live status for every endpoint
API.SH vs the official LeetCode API
We found no documented public LeetCode API in the search results. Developers usually wrap LeetCode's internal GraphQL queries in community projects on GitHub, 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 maintaining a GitHub wrapper or your own scraper, use one API.SH key with a fixed price per call and routes that are kept working for you.
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), contests (/leetcode/v1/contests and /leetcode/v1/contest), a user's public profile (/leetcode/v1/user), contest history (/leetcode/v1/user/contests) and recent accepted submissions (/leetcode/v1/user/submissions).
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?+
No. The problem route returns metadata such as difficulty, tags, acceptance rate, hints count and function signature, but not the statement text or solution code.
Can I use the LeetCode API from Python?+
Yes. Use the Python SDK, or call the HTTPS endpoints from any language with your API key. 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.