Lab 02: HTTP, API, Browser
See how browsers and APIs exchange messages.
Analogy
Section titled “Analogy”HTTP is a postal system. The URL is the address. Headers are envelope metadata. The body is the letter. Status codes are delivery results.
- Open any website in a browser.
- Open developer tools and the Network tab.
- Reload the page.
- Pick one request and record:
- URL
- method
- status
- request headers
- response headers
- response body type
- Use
curlto request a public JSON API. - Save the response.
- Change one request header and observe whether the response changes.
- Write a tiny local API with one
GET /healthroute and onePOST /echoroute. - Call both routes with
curl.
Commands To Learn
Section titled “Commands To Learn”curl -i https://example.comcurl -X POST http://localhost:3000/echo \ -H 'Content-Type: application/json' \ -d '{"message":"hello"}'Questions
Section titled “Questions”- What is the difference between a URL and an endpoint?
- What does a
404mean? - What does a
500mean? - Why should APIs validate request bodies?
- What should
/healthprove?
Artifact
Section titled “Artifact”Create http-api-browser.md with:
- Screenshot or notes from browser Network tab.
curlcommands and responses.- Local API code or link.
- Explanation of one failed request.
Done When
Section titled “Done When”You can explain one real browser request and one local API request end to end.