This project is a simple RESTful API built with Django, designed to return my profile information along with a dynamic cat fact fetched from an external API.
It’s part of the Backend Wizards Stage 0 Task, which validates understanding of REST APIs, JSON serialization, environment setup, and external API integration.
- Returns personal profile information (
name,email,GitHub,bio) - Fetches a random cat fact dynamically from catfact.ninja
- Includes status codes and error handling
- Uses environment variables for secure configuration
- Ready for deployment on Railway.app
{
"status": "success",
"profile": {
"name": "Ogochukwu Stanley Ikegbo",
"email": "stacymacbrains@gmail.com",
"github": "https://github.com/stacymacbrains",
"bio": "Backend developer passionate about APIs and Django."
},
"cat_fact": "Cats can rotate their ears 180 degrees."
}{
"status": "error",
"profile": {
"name": "Ogochukwu Stanley Ikegbo",
"email": "stacymacbrains@gmail.com",
"github": "https://github.com/stacymacbrains",
"bio": "Backend developer passionate about APIs and Django."
},
"cat_fact": "The request to fetch cat fact timed out."
}- Python 3.x
- Django 5.x
- Gunicorn (for production)
- Requests (for external API calls)
- python-dotenv (for environment variables)
- A GET request is made to
/api/me. - Django returns static profile info.
- It sends a live HTTP request to the Cat Fact API (
https://catfact.ninja/fact) with a 5-second timeout. - If successful, it combines both into a JSON response.
- If the request fails or times out, an error message and
status: "error"are returned.
git clone https://github.com/Staneering/backend-wizards-stage0.git
cd backend-wizards-stage0python -m venv venv
venv\Scripts\activate # on Windows
# or
source venv/bin/activate # on macOS/Linuxpip install -r requirements.txtCreate a .env file in the project root:
SECRET_KEY=your_django_secret_key
DEBUG=True
python manage.py runserverVisit 👉 http://127.0.0.1:8000/api/me
-
Push your code to GitHub.
-
Connect your repository to Railway.app.
-
Set your environment variables (
SECRET_KEY,DEBUG=False) in the Railway dashboard. -
Add a Procfile to the root of your project:
web: gunicorn mybackend.wsgi -
Deploy 🎉
mybackend/
│
├── api/
│ ├── __init__.py
│ ├── urls.py
│ ├── views.py
│
├── mybackend/
│ ├── __init__.py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
│
├── manage.py
├── Procfile
├── requirements.txt
└── .env
Ogochukwu Stanley Ikegbo 📧 stacymacbrains@gmail.com 🔗 GitHub: stacymacbrains
- CatFact Ninja API for the random cat facts
- Backend Wizards for the task challenge