Public data application · Edition 2

Integrate services

Explain what an API sends and where credentials must stay.

Before you begin

Work with an array of records and use a button to switch a page between states.

The practical problem

Prototype an interface for a fictional city parks directory without making a network request. A public response may include name, district and opening status, but must not include a private contact or provider key.

Build it step by step

  1. Write sample records in one local module and a small rendering function in another.
  2. Create separate demo states for success, no results and temporary failure.
  3. Document the public response contract, what can be cached, and where a real secret would be stored in a future deployment.

Acceptance criteria

  • A normal sample shows park names and current fictional statuses.
  • An empty array yields “No parks match” rather than an error.
  • A failed state explains a safe retry; no real network or credentials are involved.

Common mistake

Do not confuse an empty result with failed access or ship a real API key in a public script.

How to assess your work

Run the checks below and write down what you expected, what happened, and one change you can demonstrate. Self-checks are practice evidence, not a verified grade.

Build

Write an API contract for a fictional public park listing. Use an example JSON file instead of making external requests. Identify any fields you would not publish.

Test

Try a well-formed response, an empty response, and an error. Explain what the interface should show in each case, and where any real key would belong.

Reflect

What is the difference between a public API response and a credential?

Starter project and AI hint

Use a fictional example with park name, district, and opening status. Sketch empty and error states.

Ask how the interface can distinguish an empty response from a failed request.