LeetCode primarily has a GraphQL API without official REST support or documentation, this project aims to make accessing LeetCode data more approachable by providing a simple and user-friendly REST API—eliminating the need to manually write GraphQL queries.
- Fetch LeetCode user profiles, badges, submissions, contests, calendars, and problems
- Easy-to-use REST endpoints
- Built with TypeScript
- Easily testable via Postman
src/api— Functions for making API calls to LeetCodesrc/graphql— GraphQL queries extracted via LeetCode's network tabsrc/routes— Route handlers for user and problem-related endpointssrc/services— Controller logic linked to routessrc/types— TypeScript type definitionssrc/index.ts— Application entry point
-
Clone this repository:
git clone https://github.com/VarshithSoma/leetcode-graphql-to-rest.git cd leetcode-rest-api -
Install dependencies:
yarn install
-
Create config.env file and add PORT
PORT=9009
-
Start the development server:
yarn run dev
-
To compile TypeScript to JavaScript, run:
tsc -b
https://leetcode-graphql-to-rest.onrender.com| Endpoint | Description |
|---|---|
GET /:username |
Get user profile Data |
GET /:username/getBadges |
Get user Badges |
GET /:username/userSubmissions/:limit |
Get user Submissions |
GET /:username/acUserSubmissions/:limit |
Get Accepted user Submissions |
GET /:username/userCalendar |
Get user submission Calendar |
GET /:username/allContests |
Get all Contest |
GET /:username/allAttendedContests |
Get all attended user Contests |
GET /problems/:limit |
Get leetcode problems data |
| Command | Description |
|---|---|
yarn run dev |
Run server with nodemon |
yarn build |
Compile TypeScript |
yarn start |
Start server from built JS |