Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mutasim77/leetcode-api
πΈοΈ Go-based REST API that acts as a wrapper for LeetCode's GraphQL API, allowing users to fetch LeetCode user information via simple HTTP requests. π‘
https://github.com/mutasim77/leetcode-api
golang graphql leetcode rest-api
Last synced: 23 days ago
JSON representation
πΈοΈ Go-based REST API that acts as a wrapper for LeetCode's GraphQL API, allowing users to fetch LeetCode user information via simple HTTP requests. π‘
- Host: GitHub
- URL: https://github.com/mutasim77/leetcode-api
- Owner: mutasim77
- License: mit
- Created: 2024-06-23T12:42:27.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-08-12T04:14:55.000Z (3 months ago)
- Last Synced: 2024-08-12T05:29:03.138Z (3 months ago)
- Topics: golang, graphql, leetcode, rest-api
- Language: Go
- Homepage:
- Size: 16.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LeetCode REST API Wrapper (LRAW) π
## Description π
LRAW is a Go-based REST API that simplifies access to LeetCode user data. It wraps LeetCode's GraphQL API, providing an easy-to-use REST interface for developers.## Features β¨
- Fetch user information by username
- Simple REST API endpoints
- Dockerized for easy deployment
- Modular codebase structure## Why this project? π€
### Problem π€
Another day I was making a platform for LeetCode users, but I realized there's no official API from LeetCode. Some people have made their own ways to do this, but I didn't really like them. LeetCode is nice, but it does not have a REST API (which is easy to use for the majority). It provides GraphQL, but not everyone is familiar with it, and LeetCode does not officially provide a `schema` even for that GraphQL. This lack of documentation and the complexity of GraphQL can be a significant hurdle for many developers who want to build applications using LeetCode data.### Solution π‘
To fix this, I made this project. I like using Go, so I wrote it in Go. I spent some time figuring out how to get data from LeetCode, and I found the right GraphQL queries to use.This project changes those hard-to-use GraphQL queries into a simple REST API. Now, developers can easily get all the info about any LeetCode user by just making a simple request with the username. This makes it much easier to use LeetCode data in other apps, even if you don't know how to use GraphQL.
## Installation π οΈ
1. Clone the repository
```bash
git clone https://github.com/mutasim77/leetcode-api.git
```
2. Navigate to the project directory
```bash
cd leetcode-api
```
3. Install dependencies
```bash
go mod tidy
```## Usage π₯οΈ
### Running locally π
1. Start the server
```bash
go run cmd/server/main.go
```
2. Make a GET request to `http://localhost:8080/user/{username}`> [!TIP]
> By default, the server runs on port `8080`. You can change this by setting the `PORT` environment variable:
>
> `PORT=3000 go run cmd/server/main.go`
>
> This would start the server on port `3000`.### Using Docker π³
1. Build the Docker image
```bash
docker build -t leetcode-api .
```
2. Run the container
```bash
docker run -p 8080:8080 leetcode-api
```## API Endpoints π£οΈ
- GET `/user/{username}`: Fetch user information## Development π»
- To run tests:
```bash
go test ./test
```
- To build the binary:
```bash
go build -o leet-api cmd/server/main.go
```## Deployment π
LRAW can be easily deployed on platforms like:
- Google Cloud Run
- AWS ECS (Elastic Container Service)
- Heroku (with container runtime)
- DigitalOcean App PlatformRefer to each platform's documentation for specific deployment instructions.
## License π
This project is [MIT](./LICENCE) licensed.