NEW
Font size
WorksheetsHackharbor 3.0 : Day 5 API and JSON Quiz
Total questions: 27
Worksheet time: 14mins
What is the role of an API in software communication?
It compiles frontend code
It directly connects databases
It acts as a messenger between software components
It generates UI elements
Which real-world analogy best represents an API?
Chef cooking food
Menu in a restaurant
Waiter taking your order
Receipt after payment
Which of the following is NOT a benefit of APIs?
Promotes modularity
Improves reusability
Increases memory usage
Adds a security layer
You exposed your API key on GitHub. What happens next?
Congratulations! Free server hosting.
The API retires
Hackers thank you
Nothing, everything is secure (just kidding)
What does the URL https://api.openweathermap.org/data/2.5/weather?q=Delhi&appid=API_KEY represent?
An email request
A database insertion
A weather API GET request
A file download from a server
Which one is NOT a valid status code?
204 No Content
301 Moved Permanently
777 Lucky Response
403 Forbidden
Which HTTP method is used to retrieve data from a resource?
PUT
POST
GET
DELETE
What does the POST method typically do?
Read data from server
Create new resource
Delete existing resource
Authenticate the user
What’s the expected output of a GET /posts/1 call to JSONPlaceholder?
A JSON object with post details
A string response
A login prompt
A file download
What does HTTP status code 201 mean?
Resource not found
Resource successfully created
Internal server error
Authentication failed
What’s the scariest word in web development?
Callback
Merge Conflict
CORS
API Downtime
Which of these HTTP status codes indicate a client-side error?
200
500
404
301
Why would you use Postman instead of writing raw fetch code?
It can host websites
It allows visual testing of APIs
It compiles JS code
It encrypts data in real-time
What tab in Postman do you use to input a JSON request body?
Headers
Params
Body
Console
What’s an API’s favorite position?
On the frontend
In the kitchen
In the middle, taking orders
Hiding in the backend
Which of these headers must be included in a JSON POST request?
Accept-Encoding
Content-Type: application/json
Authorization: admin
Cookie: true
In JSON, all string values and keys must be:
Single quoted
Escaped with slashes
In double quotes
Left unquoted
Which of these is a valid JSON?
{ name: 'Alice' }
{ "name": "Alice" }
{ name = "Alice" }
["name": "Alice"]
What happens if you send malformed JSON in a POST request?
It silently fails
Server throws a 200 OK
Server returns a 400 Bad Request
It still saves data
Why don’t APIs use Tinder?
They prefer RESTful relationships
They’re always busy
They already found their endpoints
They only GET, never POST
Which JavaScript method converts an object into JSON?
parse()
stringify()
convert()
serialize()
What is the primary difference between res.send() and res.json() in Express?
One sends images, the other doesn't
send() can send anything; json() ensures valid JSON
send() is deprecated
json() only works on frontend
What does req.query contain in Express?
POST body
JSON payload
URL query parameters
Auth headers
What error would you get if a frontend hits an API with no CORS enabled?
404 Not Found
CORS Policy Error
JSON Parsing Error
Bad Gateway
Why did the API go to therapy?
It had unresolved parameters
It kept getting rate-limited
It was always POSTing too much
It had trust issues with headers
What should you use to hide your API keys in real projects?
Postman
.env files
HTML comments
JSON config in frontend
Why did JSON get dumped?
Too many nested issues
Too verbose
Didn’t quote things properly
It wasn’t REST-ful enough
