This project is a FastAPI-based HTTP server that interacts with the GitHub Gists API
This responds to requests on /<USER> with a list of the user’s publicly available Gists.
It uses caching for efficiency, logging for observability, and include a test for validation.
├── app
│ ├── __init__.py
│ ├── main.py # FastAPI application entrypoint
│ └── schema.py # Pydantic models for response validation
│
├── tests
│ └── test_main.py # Pytest-based API tests
│
├── Dockerfile # Multi-stage Docker build for production
├── requirements.txt # Python dependencies
-
Clone the repository
git clone https://github.com/EqualExperts-Assignments/equal-experts-fortunate-astonishing-impeccable-professor-857ba32a0786.git cd equal-experts-fortunate-astonishing-impeccable-professor-857ba32a0786 -
Create a virtual environment (optional but recommended)
python3 -m venv venv source venv/bin/activate -
Install dependencies
pip install -r requirements.txt -
Run the server
uvicorn app.main:app --reload
Optionally you can add --port <potr_number> if you want server to run on a specific port
-
Go in the directory where Dockerfile is present and run the following command to build the Docker image
docker build -t gists-api . -
Run the container
docker run -p 8080:8080 gists-api
API will be available at:
http://localhost:8080
GET /{user}?per_page={int}&page={int}
-
user: GitHub username (required) -
per_page: Number of gists per page (default: 10) -
page: Page number (default: 1)
Example curl http://127.0.0.1:8000/octocat?per_page=5&page=1
Response (shortened example)
[
{
"id": "6cad326836d38bd3a7ae",
"url": "https://api.github.com/gists/6cad326836d38bd3a7ae",
"...": "other fields allowed"
}
]
To run tests locally:
pytest
-
The schema only validates
idandurl, while allowing extra fields to remain flexible against GitHub API changes. -
Results are cached for 5 minutes to avoid repeated GitHub API calls.
-
Error handling:
-
404: User not found -
500: Internal server error
-