DEV Community

Cover image for 🐱 My HNG 13 Stage 0 Task β€” Building a Simple Cat Facts API with FastAPI
John Afariogun
John Afariogun

Posted on

🐱 My HNG 13 Stage 0 Task β€” Building a Simple Cat Facts API with FastAPI

After getting to the penultimate stage in HNG12 internship earlier this year, my perfectionist tendencies cropped up again and this time I want to get to the ultimate stage. First though I have to start from the scratch so stage 0 it is.

The goal for Stage 0 was straightforward:

πŸ‘‰ Build a small backend application that returns some personal info β€” and something extra (Cats facts).


πŸš€ Project Overview

This project, called Cat Facts API Integration, fetches random cat facts from the public Cat Facts API and combines them with basic user information.

It includes three simple endpoints:

  • / β†’ Root welcome route
  • /health β†’ Health check
  • /me β†’ My personal info + a random cat fact

All built with FastAPI, httpx, and a bit of structured logging.


🧩 Project Structure


HNG13_simple_rest_stage_0/
β”œβ”€β”€ app.py
β”œβ”€β”€ app.log
β”œβ”€β”€ requirements.txt
└── README.md

Enter fullscreen mode Exit fullscreen mode


`

The app includes:

  • FastAPI for routing and documentation
  • httpx for making async API requests
  • logging for monitoring
  • CORS middleware for flexible frontend integration if need be

🧭 Endpoints Documentation

Method Endpoint Description
GET / Root endpoint that returns a welcome message.
GET /health Confirms that the API is healthy and reachable.
GET /me Returns user info (email, name, stack) along with a random cat fact.

πŸ§ͺ Example Response

GET /me

json
{
"status": "success",
"user": {
"email": "afariogun.john2002@gmail.com",
"name": "John Afariogun",
"stack": "Python/FastAPI"
},
"timestamp": "2025-10-15T10:00:00Z",
"fact": "Cats sleep for around 70% of their lives."
}


🧰 Running the App Locally

To test this project on your system:

bash
git clone https://github.com/johnafariogun/HNG13_simple_rest_stage_0
cd HNG13_simple_rest_stage_0
pip install -r requirements.txt

Then start the server:

bash
python app.py

Visit these URLs in your browser:

You can checkout (mine)[https://hng13simplereststage0-production.up.railway.app/me]

πŸ“Έ OpenAPI Documentation

FastAPI automatically provides Swagger UI for your routes:

🧭 Navigate to /docs
You’ll see your /, /health, and /me routes neatly documented β€” no extra setup needed!


🌍 Deployment

So I deployed this on Railway

You can check out how to deploy a fastapi app on railway at the official docs


πŸ’‘ What I Learned

  • How to set up a simple FastAPI app
  • How to call external APIs asynchronously using httpx
  • How to implement logging and error handling
  • How to structure JSON responses neatly
  • The power of automatic documentation in FastAPI
  • How to deploy using Railway

πŸ”š Conclusion

Stage 0 may look simple, but it’s where the foundation for cleaner, production-ready APIs begins.

This project taught me how small things β€” like handling timeouts, errors, and logs β€” make a huge difference when building real backend systems.

Next step? Stage 1 of HNG 13, probably focusing on testing, deployment, and CI/CD πŸš€


πŸ‘¨β€πŸ’» Author: John Afariogun
Stack: Python / FastAPI
GitHub: @johnafariogun
Email: afariogun.john2002@gmail.com

`

Top comments (0)