Read a request and response contract
See this course’s project requirements
A tested local API-response viewer with a request contract, validation rules, six response cases and an honest integration handoff.
Keep your working files in your own notebook or software. Save a private description, checklist, and work link in My Proof.
What to include
- Request/response contract with limits.
- Type and status observations.
- Working local viewer.
- Explicit empty/error/validation behavior.
- Six-case test matrix and README.
Review and revise
Use these criteria to check your work and choose what to improve.
- Fields and types are understood.
- Failures do not show stale results.
- All six cases behave as described.
- Simulation and live-integration limits are explicit.
Want more background?
The idea in everyday life
Build a read-only viewer for a fictional library-hours API contract.
An API contract says how one program asks and what another program promises to return.
Read a request and response contract — guided practice
Identify the method, path and expected response fields.
Save api-viewer.html from the download and open it in a modern browser. Open its source in a text editor. The complete original file supplies every fixture and function. It simulates GET /hours locally; it does not contact a real library. Reload after edits; restore the supplied file before each lesson unless told otherwise.
1. Read the request
Find mockRequest and the call inside loadHours. Write method GET and path /hours.
You should see: The request asks to read hours.
Method and path identify the intended operation.
2. Read the schema
Inspect success: branches is an array; each item has id/name strings and opens/closes integer hours.
You should see: Two records match that shape.
A response can be valid JSON yet violate the expected schema.
3. Run a success
Choose success and click Load hours.
You should see: Central: 10–18 (8 hours); East: 12–17 (5 hours).
An observed result connects the contract to use.
4. Record limits
Write that times are fictional same-day whole hours and no time zone/date is modeled.
You should see: The handoff does not imply live opening hours.
A small training schema cannot answer unstated real-world questions.
What to finish
A request/response contract note.
Watch for this
Treating a fictional practice response as current real opening hours.
How can I tell I understand it?
Complete the changed case, explain your result, and pass the three application checks.
Quick knowledge check
Answer all 3 questions. Get at least 2 right and the lesson completes automatically.
You’ll get an explanation for each answer. Signed in? Your results save to your account.
Pass the check. We’ll save the progress.
Answer all 3 questions above and get at least 2 right. You can review the explanations and try again.
Go to the knowledge checkOptional course overview video
APIs for Beginners - How to use an API (Full Course / Tutorial)
From freeCodeCamp.org. Watch here or open it on YouTube .
Optional course overview. Follow the written steps below at your own pace.Tools, templates, and lesson sources
Tools and templates
Tools open in a new tab so you can keep your place here.
Sources and further reading
Explore the references behind this lesson.
Source & access notes · checked 2026-09-12
Opened and inspected on 2026-09-12: JSON types and parsing.
Access: Free public web page; no paid enrollment required.
Reuse: Public reference; link only. LifeStarter prose, exercises and files are independently authored.
Source & access notes · checked 2026-09-12
Opened and inspected on 2026-09-12: Responses, promises and explicit HTTP status checks.
Access: Free public web page; no paid enrollment required.
Reuse: Public reference; link only. LifeStarter prose, exercises and files are independently authored.
Source & access notes · checked 2026-09-12
Metadata retrieved and inspected on 2026-09-12: exact title and channel confirmed through YouTube oEmbed. Playback and full video content were not tested. Optional overview; the written lesson and supplied practice stand alone.
Access: Free public web page; no paid enrollment required.
Reuse: Link or provider embed only; do not copy video, audio or transcript.
Report a problem with this lesson
Tell us what went wrong. Please leave out personal information and private project contents.