WrapperGithubApi is a backend service designed to support the RepEx - GitHub Repositories Explorer project. This API acts as a secure wrapper around GitHub's REST and GraphQL APIs, hiding the GitHub token to prevent exposure on the frontend.
This project serves as a secure intermediary layer for GitHub data access in the RepEx project (GitHub Repository Explorer).
- Secure GitHub API access (REST & GraphQL)
- Built with FastAPI + Uvicorn for high performance
- Response time logging via middleware
- Centralized error handler for consistent API responses
- Centralized configuration using
pydantic_settingsfor cleaner and consistent environment management - Rate limiting using SlowAPI to prevent abuse
- Middleware integrations: CORS, GZip, Trusted Host
- Secure headers via middleware to prevent Clickjacking, XSS, and insecure redirects
- Built-in caching using
cachetools - OpenAPI and ReDoc auto-generated documentation at
/docsand/redoc docker-compose.ymlto assist local development by provisioning Redis, Redpanda, Redpanda Console, Prometheus, and Grafana services.
- Python: The primary programming language.
- FastAPI: A modern, fast (high-performance) web framework for building APIs with Python.
- HTTPX: An async HTTP client for making requests to the GitHub API.
- python-dotenv: A library to load environment variables from a
.envfile, ensuring that sensitive data (like GitHub tokens) remains secure. - Uvicorn: An ASGI server to run the FastAPI application.
- Cachetools: A caching library used to store frequently requested data to optimize performance and reduce load on the GitHub API.
- SlowAPI: A FastAPI-compatible rate limiter used to prevent API abuse by restricting the number of requests per client.
- pydantic_settings: A library for managing application configuration using Pydantic models.
- redis: A caching solution used to store frequently accessed data externally, helping to improve performance and minimize load on the GitHub API.
- aiokafka: An asynchronous client library for producing and consuming messages with Kafka.
Check if Python is installed
You can verify by running:
python --version
If Python is not installed, download and install it from the official website: https://www.python.org/downloads/
Clone the repository
git clone https://github.com/yourusername/WrapperGithubApi.git cd WrapperGithubApi(Optional) Create a virtual environment
It’s recommended to use a virtual environment to isolate project dependencies:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
Install the required dependencies
pip install -r requirements.txt
(Optional) If you have Docker installed, you can spin up the services using
docker-compose.yml:if docker compose version v2
docker compose up -d
or
docker-compose up -d
Set up environment variables
Create a
.envfile in the project root directory based on the provided.env.example:AUTH_TOKEN=your_github_token# OptionalREDIS_URL=redis://localhost:6379# OptionalKAFKA_SERVER=localhost:19092# OptionalLOGGING_LEVEL=INFO# DEBUG for full logging
Run the application
Start the FastAPI app using Uvicorn:
uvicorn app.main:app --reload
The server will be available at: http://localhost:8000
| Method | Endpoint | Description |
|---|---|---|
| GET | /repos | List repositories |
| GET | /user | Get user info |
| GET | /search | Search GitHub users or repository. |
| POST | /graphql | Submit GraphQL queries to GitHub's GraphQL API. |
Click to expand full list
| Method | Endpoint | Description |
|---|---|---|
| GET | /repositories | List public repositories |
| GET | /repos/{user}/{repo} | Repo detail |
| GET | /repos/{user}/{repo}/stargazers | List repo stragazers |
| GET | /repos/{user}/{repo}/subscribers | List repo subscribers |
| GET | /repos/{user}/{repo}/contributors | List repo contributors |
| GET | /repos/{user}/{repo}/branches | List repo branches |
| GET | /repos/{user}/{repo}/activity | List repo activity |
| GET | /repos/{user}/{repo}/pulls | List repo pulls |
| GET | /repos/{user}/{repo}/issues | List repo issues |
| GET | /repos/{user}/{repo}/languages | List repo languages |
| GET | /repos/{user}/{repo}/topics | List repo topics |
| GET | /repos/{user}/{repo}/readme | Repo readme detail |
| Method | Endpoint | Description |
|---|---|---|
| GET | /users/{user} | Get user info |
| GET | /user/{user}/repos | List user repos |
| GET | /user/{user}/followers | List user followers |
| GET | /user/{user}/starred | List user starred repos |
| GET | /user/{user}/events/public | List user activity |
| Method | Endpoint | Description |
|---|---|---|
| GET | /search/users | Search Github user |
| GET | /search/repositories | Search repository |
| Method | Endpoint | Description |
|---|---|---|
| POST | /graphql/query | Request GitHub's GraphQL API |
| POST | /graphql/searchUser | Search Github user with custom content |
Interactive API documentation available at:
Once the server is up and running, you can access the available endpoints:
Get repository info:
GET /repos/octocat/Hello-World
Get user data:
GET /user/octocat
Query GraphQL:
POST /graphql/queryContent-Type: application/json { "query": "{ viewer { login } }" }
Contributions are welcome! Please open an issue or submit a pull request for any improvements or fixes.
This project is licensed under the MIT License - see the LICENSE file for details.
This project is part of RepEx - GitHub Repositories Explorer. Check out the main repository for more information.