leetinfo-api

An open-source serverless API (Vercel + Go) for public LeetCode profile data — REST endpoints, a shields.io-compatible endpoint, and ready-to-embed SVG badges for your README.

solved badge streak badge ranking badge

Try it now

Enter a LeetCode username to see the API's real response and the generated badges.

GET API routes

All routes return JSON and require the username query parameter. Base URL: https://your-instance.vercel.app

GET/api/user?username=<user>

Full profile: question counts by difficulty, profile info (ranking, reputation, avatar), submit stats, recent submissions, and computed streak.
curl "https://your-instance.vercel.app/api/user?username=reinanbr"

GET/api/streak?username=<user>

Current streak and longest daily-submission streak, computed from the submission calendar.
{
  "totalSubmissions": 10,
  "currentStreak": 0,
  "longestStreak": 2
}

GET/api/stats

Accepted vs. total submissions, grouped by difficulty (Easy/Medium/Hard/All).

GET/api/submissions

Recent submissions (title, language, status, timestamp). Accepts an optional &limit=.

Shields.io integration

/api/shields returns the JSON schema that shields.io's dynamic endpoint badge expects — useful if you already use shields.io elsewhere in your README and want a consistent look.

GET/api/shields?username=<user>&stat=<stat>

ParameterRequiredDescription
usernameyesLeetCode username
statnosolved (default), easy, medium, hard, ranking, reputation, contributions, streak, longeststreak, or totalsubmissions
labelnoOverrides the left-hand label text
colornoOverrides the color (shields.io name or hex)
https://img.shields.io/endpoint?url=https://your-instance.vercel.app/api/shields?username=reinanbr%26stat=solved

In Markdown:

![LeetCode solved](https://img.shields.io/endpoint?url=https://your-instance.vercel.app/api/shields?username=reinanbr%26stat=solved)

SVG badges (no shields.io dependency)

/api/badge renders the SVG directly — simpler to embed, with no extra round trip through shields.io.

GET/api/badge?username=<user>&stat=<stat>

ParameterRequiredDescription
usernameyesLeetCode username
statnosolved (default), easy, medium, hard, ranking, reputation, contributions, streak, longeststreak, totalsubmissions
labelnoOverrides the left-hand label text
colornoShields.io color name (brightgreen, orange, blue...) or hex (#ff69b4)
stylenoflat (default) or flat-square
badge preview /api/badge?username=reinanbr&stat=solved

In Markdown:

![LeetCode solved](https://your-instance.vercel.app/api/badge?username=reinanbr&stat=solved)

Errors & caching

JSON routes (/api/user, /api/stats...)

Missing username or a user that doesn't exist → 400/404 with { "error": "..." }. Cache: s-maxage=300.

/api/shields and /api/badge

Never return an HTTP error — always 200 with a red error badge/JSON, so the embedded README image never breaks. Cache: s-maxage=3600 on success.