<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Titilola Olaitan</title>
    <description>The latest articles on DEV Community by Titilola Olaitan (@titilola_olaitan).</description>
    <link>https://dev.to/titilola_olaitan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2660720%2F965b9d94-ddc5-4dc3-9c18-a65c5eb38a41.jpg</url>
      <title>DEV Community: Titilola Olaitan</title>
      <link>https://dev.to/titilola_olaitan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/titilola_olaitan"/>
    <language>en</language>
    <item>
      <title>My First API Just Broke (And That Was the Point)</title>
      <dc:creator>Titilola Olaitan</dc:creator>
      <pubDate>Fri, 17 Oct 2025 22:56:48 +0000</pubDate>
      <link>https://dev.to/titilola_olaitan/my-first-api-just-broke-and-that-was-the-point-337k</link>
      <guid>https://dev.to/titilola_olaitan/my-first-api-just-broke-and-that-was-the-point-337k</guid>
      <description>&lt;p&gt;Day 1 of my internship. The task seemed simple: "Build an API endpoint that returns your profile and a cat fact."&lt;br&gt;
How hard could it be? Spoiler: I learned more from this "simple" task than from watching 10 hours of tutorials.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Challenge
&lt;/h2&gt;

&lt;p&gt;Build a /me endpoint that:&lt;/p&gt;

&lt;p&gt;Returns my profile info&lt;br&gt;
Fetches random cat facts from an external API&lt;br&gt;
Updates timestamp on every request&lt;br&gt;
Doesn't crash when things go wrong&lt;/p&gt;

&lt;h2&gt;
  
  
  My Stack: Python + FastAPI
&lt;/h2&gt;

&lt;p&gt;The "Aha!" Moments&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;External APIs Are Unreliable (And That's Normal)
My first version looked like this:
&lt;code&gt;python@app.get("/me") 
async def get_profile():
response = await client.get("https://catfact.ninja/fact")
cat_fact = response.json()["fact"]
return {"fact": cat_fact, ...}&lt;/code&gt;
What could go wrong?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;API is down → My app crashes&lt;br&gt;
API is slow → User waits forever&lt;br&gt;
API returns weird data → App explodes&lt;/p&gt;

&lt;p&gt;The fix: Timeouts + error handling + fallbacks&lt;br&gt;
&lt;code&gt;pythonasync def fetch_cat_fact():&lt;br&gt;
    try:&lt;br&gt;
        async with httpx.AsyncClient(timeout=5.0) as client:&lt;br&gt;
            response = await client.get(CAT_FACT_API_URL)&lt;br&gt;
            return response.json()["fact"]&lt;br&gt;
    except:&lt;br&gt;
        return "Cat facts temporarily unavailable"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Lesson learned: Always plan for failure. Production apps need to be resilient, not just functional.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Environment Variables Aren't Just for Secrets
I hardcoded my email in the code at first. Then I realized:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;What if I want to change it?&lt;br&gt;
What if someone else uses my code?&lt;br&gt;
What about deployment?&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Created .env for my actual data:&lt;br&gt;
bashUSER_EMAIL=john@example.com&lt;br&gt;
USER_NAME=John Doe&lt;br&gt;
Created .env.example for the template:&lt;br&gt;
bashUSER_EMAIL=your.email@example.com&lt;br&gt;
USER_NAME=Your Name&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Lesson learned: Separate configuration from code. Future you will thank present you.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;FastAPI's Auto-Docs Saved Me Hours&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hit localhost:8000/docs and boom.....interactive API documentation, automatically generated. I could test everything right in the browser without writing a single line of test code.&lt;/p&gt;

&lt;p&gt;Lesson learned: Choose tools that give you superpowers for free.&lt;/p&gt;

&lt;p&gt;The Final Result&lt;br&gt;
Live API: [&lt;a href="https://profile-api-production-f700.up.railway.app/me" rel="noopener noreferrer"&gt;https://profile-api-production-f700.up.railway.app/me&lt;/a&gt;]&lt;br&gt;
&lt;code&gt;json{&lt;br&gt;
  "status": "success",&lt;br&gt;
  "user": {&lt;br&gt;
    "email": "john@example.com",&lt;br&gt;
    "name": "John Doe",&lt;br&gt;
    "stack": "Python/FastAPI"&lt;br&gt;
  },&lt;br&gt;
  "timestamp": "2025-10-17T14:30:45.123456+00:00",&lt;br&gt;
  "fact": "Cats sleep 70% of their lives."&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
Every request fetches a new cat fact. Every timestamp is fresh. And when the cat API goes down? My API keeps working.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwych40stmqjkr8ybxhv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvwych40stmqjkr8ybxhv.png" alt="API response in browser(JSON)" width="800" height="382"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmw9sldy5bxyeu0yqhl0g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmw9sldy5bxyeu0yqhl0g.png" alt="FastAPI docs" width="800" height="386"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;What This Task Actually Taught Me&lt;br&gt;
Beyond the code:&lt;/p&gt;

&lt;p&gt;Error handling &amp;gt; happy path — Production is messy&lt;br&gt;
Async is powerful — Don't block your API&lt;br&gt;
Never commit secrets — .gitignore is your friend&lt;br&gt;
Documentation matters — README = first impression&lt;br&gt;
Deploy early, deploy often — See your code in production&lt;/p&gt;

&lt;p&gt;The unexpected lesson: A "simple" task reveals how much you don't know. And that's exactly the point of learning.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1hx1mnhc51ndafbe8jn1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1hx1mnhc51ndafbe8jn1.png" alt="Railway Dashboard - showing " width="800" height="441"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfy3jom11ibj9kfos5pe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftfy3jom11ibj9kfos5pe.png" alt="Railway Logs - showing successful deployment" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Stack
&lt;/h2&gt;

&lt;p&gt;Framework: FastAPI (because async + auto-docs = ❤️)&lt;br&gt;
HTTP Client: httpx (for async requests)&lt;br&gt;
Deployment: Railway (GitHub integration made it painless)&lt;br&gt;
External API: Cat Facts API&lt;/p&gt;

&lt;p&gt;Try It Yourself&lt;br&gt;
GitHub: [&lt;a href="https://github.com/Titilola-py/profile-api" rel="noopener noreferrer"&gt;https://github.com/Titilola-py/profile-api&lt;/a&gt;]&lt;br&gt;
Live Demo: [&lt;a href="https://profile-api-production-f700.up.railway.app/me" rel="noopener noreferrer"&gt;https://profile-api-production-f700.up.railway.app/me&lt;/a&gt;]&lt;br&gt;
Clone it. Break it. Fix it. Learn.&lt;/p&gt;

&lt;p&gt;Questions? Built something similar? Drop a comment! I'd love to see what you created or hear about your first API experience.&lt;/p&gt;

&lt;p&gt;Connect with me here:&lt;br&gt;
GitHub: [&lt;a href="https://github.com/Titilola-py" rel="noopener noreferrer"&gt;https://github.com/Titilola-py&lt;/a&gt;] | LinkedIn: [&lt;a href="https://www.linkedin.com/in/fatimah-olaitan-4bb6602a4/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/fatimah-olaitan-4bb6602a4/&lt;/a&gt;] | Twitter: [&lt;a href="https://x.com/thetitilola" rel="noopener noreferrer"&gt;https://x.com/thetitilola&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>python</category>
      <category>fastapi</category>
      <category>internship</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
