Backend Engineering in Action - FastAPI + REST API + External API Integration

Backend Engineering in Action - FastAPI + REST API + External API Integration

I built and deployed a RESTful API endpoint as part of a backend engineering challenge, and I decided to share my process and takeaways. It is a simple RESTful API that retrieves profile and cat facts from https://catfact.ninja/fact.

Task Overview

The goal was to create a /me endpoint that:

1. Returns profile JSON data

2. Fetches a live cat fact from an external API

3. Uses proper response formatting

4. Includes dynamic timestamps in ISO 8601 UTC format

5. Handles error states gracefully

6. Hosted on a platform NOT including Vercel

7. Includes testing and CI readiness

I chose the following stack:

• Language: Python Programming Language

• Framework: FastAPI

• HTTP Client: httpx

• Deployment: Railway

• Testing: Pytest + AsyncClient

• Logging + Environment Config: Built-in logging + dotenv

My Development Process

Step 1: Project Scaffolding

I structured the app cleanly, ensuring readability and future scalability with .env support and clear separation of logic.

Step 2: External API Integration

I integrated https://catfact.ninja/fact using async requests and configured timeout + fallback logic for reliability.

Step 3: JSON Response Contract

I followed a strict response structure with fields: status, user, timestamp, and fact.

Step 4: Error Handling

Implemented clear and resilient handling for:

• Network failures

• Timeout issues

• Unexpected JSON responses

Step 5: Testing

I wrote automated tests to validate:

• Response structure

• Dynamic timestamp

• Cat fact existence

• HTTP 200 behaviour

Step 6: Deployment to Railway

Configured a Procfile, environment variables, and uvicorn runner for production deployment. Successfully hosted the API publicly.

What I Learned / Improved

This task sharpened my:

I. API reliability practices

II. Async programming with FastAPI

III. External API consumption patterns

IV. Writing robust JSON contracts

V. Deployment automation with Railway

VI. Testing async FastAPI apps

Screenshots Attached

• FastAPI project structure

Article content

• /me API response in browser

Article content

• /docs API documentation

Article content

• Test results (pytest)

Article content

• Railway deployment dashboard

Article content

• GitHub repo + README

Article content

Demo Endpoint (Live Example)

https://web-production-686f3.up.railway.app/me

GitHub Repo:

https://github.com/triplee12/CatFacts

I'd love to connect if you are working on backend engineering, Python, or API architecture. I am always open to collaboration and deeper tech conversations!

#BackendDevelopment #FastAPI #Python #RESTAPI #DevOps #Railway #SoftwareEngineering #CloudDeployment #OpenSource #AsyncPython HNG Tech

Perfect example of backend engineering done right!

✅ Successfully completed 20+ orders on Fiverr in Python, FastAPI, Flask, React, Kubernetes, and Deployment Automation — helping clients build scalable, production-ready applications. 📌 Fiverr Profile: https://lnkd.in/dDVqHj5C 💼 I’m available for Full-time or Part-time opportunities in: - Python (FastAPI, Flask, Django) . LLM Integration , Pydantic AI Agents - React Frontend Development - Kubernetes & Docker Deployments - API Development & Integration Let’s connect if you’re looking for high-quality, on-time solutions.

Like
Reply

To view or add a comment, sign in

More articles by Chukwuebuka Ejie

Others also viewed

Explore content categories