API Fundamentals
/Intermediate
API Troubleshooting Questions
Definition
Questions that test your ability to diagnose and fix broken APIs, network failures, and integration bugs.
Explain Like I'm New
The API is broken. The interviewer gives you symptoms and expects you to play detective to find the root cause.
Real World Example
Being asked: 'A user says they cannot log in. The backend logs show no errors. The network tab shows the `/login` request stays 'Pending' forever and then times out. What is wrong?'
Common Use Cases
- •Practical coding interviews
Terminal Output
bash / terminal
/*
Debugging Scenario: The N+1 Problem
Symptom:
The /dashboard API endpoint works, but it takes 8 seconds to load.
Diagnosis:
I would check the backend database logs. It is likely suffering from the N+1 problem.
The code fetches 100 recent orders (1 query).
Then, it loops through the orders, and for EVERY order, it makes a separate query
to fetch the User who placed it (100 additional queries).
Total: 101 queries for one API request.
Fix:
Use a SQL JOIN to fetch the Orders and the Users simultaneously in 1 single database query.
*/
Interview Questions
basic
- If an API request works perfectly in Postman, but fails with a 401 Unauthorized in your React app, what is likely the problem?
intermediate
- You get a `502 Bad Gateway` error. Where do you look to fix it?