"Yet Another LeetCode API" - Because why reinvent the wheel? (But we did anyway 🛠️)
-
Live Demo: leetcode-api-pied.vercel.app
-
Interactive Docs: leetcode-api-pied.vercel.app/docs
-
Google Sheet: View Sheet
(Daily updated LeetCode question database with sorting/filtering)Enable Filtering/Sorting:
- Select Row 3.
- 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 |
/problem/{id_or_slug} |
GET | Get problem by ID/slug | /problem/1 /problem/two-sum |
/search/{query} |
GET | Search for problems | /search?query=two%20sum |
/random |
GET | Random LeetCode problem | /random |
/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 |
/daily |
GET | Today's coding challenge | /daily |
-
Clone the repo
git clone https://github.com/yourusername/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.download
or download leetcode_questions.json
(updated daily) directly from the data
folder.
-
Always Fresh Data 🥬 Auto-updating cache system (no stale LeetCode questions!)
-
Vercel-Ready ⚡ One-click deployment with serverless architecture
-
No API Keys 🔓 Free to use with sensible rate limits
-
Real LeetCode Data 🔥 Direct integration with LeetCode's GraphQL API
Disclaimer: This project isn't affiliated with LeetCode. Use at your own risk.
Made with ❤️ by Yan-Ying Liao