HNG Internship Stage 0: Building a Profile API with Cat Facts



This content originally appeared on DEV Community and was authored by abisoyeo

The first task for the HNG Internship was to build a simple RESTful API that returns my profile information along with a random cat fact. It sounds light, but it was a great way to test the fundamentals — consuming external APIs, structuring clean JSON responses, and handling dynamic data reliably.

Setting Things Up

I started by setting up a small Express server, keeping everything clean and modular. I added dotenv for environment variables and axios to handle HTTP requests. The goal was to make sure anyone could run the project locally without hardcoding personal info like my name, email, or stack.

The /me endpoint was straightforward: return a JSON response with the required fields — status, user, timestamp, and fact. I made sure the timestamp updates dynamically with each request and followed the ISO 8601 format, so everything looks consistent.

Integrating the Cat Facts API

The fun part was fetching a random cat fact from the Cat Facts API. I used axios.get() to make a request inside the /me handler.

Of course, real APIs don’t always behave — so I added proper error handling and a fallback response just in case the external API fails. That way, the endpoint still returns a complete response even if the cat fact service goes down.

To protect the endpoint, I also included basic rate limiting with express-rate-limit — it’s good practice for any public API, no matter how small.

Lessons Learned

Even though it’s a simple endpoint, this task reminded me how much polish goes into doing things right:

  • Writing clean, predictable responses
  • Handling third-party API failures gracefully
  • Using environment variables properly
  • Keeping code readable and consistent for anyone who might review it

It also reinforced something I value in backend development — clarity over complexity. Small details like proper timestamps or helpful error messages make a huge difference.

The Final Output

Each time you hit /me, you get:

  • My profile info (from environment variables)
  • A fresh UTC timestamp
  • A brand-new cat fact fetched in real time

Sample Response

{
  "status": "success",
  "user": {
    "email": "abisoyeogunmona@gmail.com",
    "name": "Abisoye Ogunmona",
    "stack": "Node.js/Express"
  },
  "timestamp": "2025-10-17T20:55:12.345Z",
  "fact": "Cats sleep 70% of their lives."
}

Wrapping Up

Stage 0 was a solid start to the internship — a reminder that even small tasks can sharpen your discipline as a developer. It’s not about building something huge; it’s about getting the fundamentals right and paying attention to the details that make your work feel complete.


This content originally appeared on DEV Community and was authored by abisoyeo