overview

FastAPI service for public LeetCode profiles: solved counts, contests, rating history, heatmap, badges, and an SVG card. Live at leetcode-stats.tashif.codes. Source is tashifkhan/LeetCodeStatsAPI.

CodeTrace calls this for the DSA ring. Category is dsa. No caller token. The server talks to LeetCode’s public GraphQL.

Docs map#

What it returns#

Type a LeetCode username. You get the shared envelope plus the older flattened fields so old clients still parse totalSolved at the top level.

  • Solved by Easy / Medium / Hard, plus acceptance rate and ranking.
  • Contest rating, global rank, and per-contest history.
  • Submission calendar as a heatmap (view=all|last_365|year).
  • Topic bars from the same stats payload, also at /{username}/topics.
  • README card at /{username}/stats/svg.

There is no in-memory HTTP cache. Without Redis the middleware is a no-op and every GET hits GraphQL.

Live access#

Run it locally#

bash
cd LeetCode
uv sync
uv run python -m uvicorn app:app --reload --port 8002

No env vars required. Optional Redis via REDIS_URL or Upstash REST, same knobs as the other stats APIs.

Default bind if you run python app.py is port 58352. Do not rely on that next to HackerRank. Use 8002.