"Yet Another LeetCode API" - Because why reinvent the wheel? (But we did anyway 🛠️)
A high-performance, caching-enabled API wrapper for LeetCode. Built with FastAPI to provide easy access to LeetCode problems, statistics, and user data. Ideal for building dashboards, analysis tools, or just exploring LeetCode data programmatically.
- 🔥 Always Fresh Data: Auto-updating cache system ensures data is never stale.
- ⚡ Vercel-Ready: Serverless architecture ready for one-click deployment.
- 🔓 No API Keys: Open access with sensible rate limiting.
- 🛡️ Real Data: Direct integration with LeetCode's GraphQL API.
- 📈 Advanced Stats: Get detailed user skills, calendar heatmaps, and problem filters.
| Service | Link | Description |
|---|---|---|
| Live API | leetcode-api-pied.vercel.app | Base URL for API calls |
| Interactive Docs | /docs | Test endpoints interactively |
| Google Sheet | View Sheet | Daily updated DB with sorting |
Google Sheet Tip: To filter/sort, select Row 3 and go to Data > Filter views > Create new filter view.
# Get today's daily challenge
curl https://leetcode-api-pied.vercel.app/daily
# Find a problem by ID/slug
curl https://leetcode-api-pied.vercel.app/problem/1
curl https://leetcode-api-pied.vercel.app/problem/two-sum
# Get user profile (try your LeetCode username!)
curl https://leetcode-api-pied.vercel.app/user/lee215| Endpoint | Method | Description | Example |
|---|---|---|---|
/problems |
GET | All LeetCode problems | /problems |
/problems/filter |
GET | Filter problems (difficulty, etc) | /problems/filter?difficulty=Easy |
/problem/{id_or_slug} |
GET | Get problem by ID/slug | /problem/two-sum |
/problem/{id}/similar |
GET | Get similar problems | /problem/two-sum/similar |
/search |
GET | Search for problems | /search?query=two%20sum |
/random |
GET | Random problem (supports filters) | /random?difficulty=Easy |
/stats |
GET | Global problem statistics | /stats |
/tags |
GET | All topic tags w/ counts | /tags |
/problems/tag/{slug} |
GET | Get problems by tag | /problems/tag/array |
| Endpoint | Method | Description | Example |
|---|---|---|---|
/user/{username} |
GET | User profile & stats | /user/lee215 |
/user/{username}/contests |
GET | User's recent contests | /user/lee215/contests |
/user/{username}/submissions |
GET | User's recent submissions | /user/lee215/submissions |
/user/{username}/calendar |
GET | User's heatmap | /user/lee215/calendar |
/user/{username}/badges |
GET | User's badges | /user/lee215/badges |
/user/{username}/skills |
GET | User's skills stats | /user/lee215/skills |
| Endpoint | Method | Description | Example |
|---|---|---|---|
/daily |
GET | Today's coding challenge | /daily |
-
Clone the repo
git clone https://github.com/noworneverev/leetcode-api.git cd leetcode-api -
Set up virtual environment (recommended)
python -m venv venv source venv/bin/activate # Linux/MacOS venv\Scripts\activate # Windows
-
Install dependencies
pip install -r requirements.txt
-
Run the server
python run.py
Visit http://localhost:8000/docs for local Swagger docs!
Get the latest LeetCode problems. Either run:
python -m src.utils.downloador download leetcode_questions.json(updated daily) directly from the data folder.
This project is not affiliated with, endorsed, or sponsored by LeetCode. It is an independent project used for educational purposes. Use at your own risk.
Made with ❤️ by Yan-Ying Liao