I just completed Stage 0 of the HNGi13 backend internship, and it was a fantastic exercise in building a dynamic REST API from scratch using ASP.NET Core.
The task was simple on the surface: create a /me
endpoint that returns my profile information and a dynamic cat fact fetched from an external API. But it taught me a lot about real-world API practices.
Here’s how I approached it:
- Setting up the project
- Used Visual Studio to create an ASP.NET Core Web API.
- Added
User Secrets
locally and mirrored them as Azure Application Settings for deployment.
- Fetching dynamic data
- Integrated the Cat Facts API (
https://catfact.ninja/fact
) usingHttpClient
. - Added a 5-second timeout and proper error handling, returning
502 Bad Gateway
if the external API failed.
- Structuring the response
-
Returned JSON exactly matching the task spec:
{ "status": "success", "user": { "email": "...", "name": "...", "stack": "C#/.NET" }, "timestamp": "2025-10-19T14:00:00.000Z", "fact": "Cats sleep 70% of their lives." }
Used UTC ISO 8601 timestamps, ensuring every request shows the current time.
- Deployment
- Deployed on Azure App Service using Visual Studio’s publish profile.
- Added profile secrets in Application Settings for production.
- Tested
/me
endpoint from multiple networks to confirm it worked reliably.
- Key takeaways
- Learned how to consume third-party APIs safely with timeouts and error handling.
- Understood the importance of environment-specific configuration (User Secrets vs. production settings).
- Reinforced JSON response consistency and API design best practices.
Outcome
- A fully working
/me
endpoint that dynamically fetches cat facts. - Proper error handling and fallback messages in case the Cat Facts API is down.
- Ready for submission to HNGi and demonstrates clean code, proper logging, and deployment skills.
Top comments (0)