The Life Starter
0 of 6 complete0%
Course Library · Lesson 1 of 6
Digital · Guided lesson

Read a request and response contract

About 31 minutes · 6 reading + 25 practice and checks
Time includes reading, practice, and questions. Extra videos or further study are optional.
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.
Open the full course project
Want more background?
Before you begin

The idea in everyday life

Build a read-only viewer for a fictional library-hours API contract.

The idea

An API contract says how one program asks and what another program promises to return.

Follow along

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. 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. 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. 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. 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.

Now change one thing

For a branch with opens 9 and closes 16, enter its modeled open hours.

Your work

What to finish

A request/response contract note.

Common mistake

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.

Try 3 questions

Quick knowledge check

Answer all 3 questions. Get at least 2 right and the lesson completes automatically.

Not yet passed

You’ll get an explanation for each answer. Signed in? Your results save to your account.

1A documented endpoint uses GET /rooms. Which request follows it?
2An API returns valid JSON but omits a required price field. Is the response ready for calculation?
3A response has opens 13 and closes 18 under the course’s same-day contract. Duration?
0 of 3 answeredApply the lesson to a short question, then review the explanation.
1
Finish this lesson

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 check
Optional course overview video
freeCodeCamp.orgAPIs for Beginners - How to use an API (Full Course / Tutorial)YouTube
Optional course overview

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.

MDN: Working with JSON
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.

MDN: Using the Fetch API
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.

APIs for Beginners - How to use an API (Full Course / Tutorial)
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.

No sign-in needed.