Dog API lab / Teacher field guide

Teach APIs with a dog-photo request

Follow a photo request with your class, find the breed label in the returned image address, and explain why reading that label differs from recognizing the image. Students can then edit and keep their own dog-photo webpage.

Suggested for high-school learners and curious beginners. Timing and suitability are teacher judgments, not results from classroom testing.

Leave with a working webpage

Download the single HTML file. Students can save it on a computer, open it in a browser and fetch a photo. No installation or key is needed; new photos require internet access. On managed devices, check that local HTML files and Dog CEO are allowed.

Pair challenge: one person follows the request; the other explains how its response becomes a picture. Swap roles. Change the heading in a text editor, save, then refresh the browser. What should the page do if the service does not respond?

The page works with a browser and an API. Pip’s agent choices in the main lesson are scripted; no model runs.

Before the bell

Prepare the classroom activity

Bring

A modern browser, internet access and a projector or one device per pair. No coding experience is needed for the main activity. Code examples are an optional extension.

Open the lab on your school network first. It contacts dog.ceo for data and images.dog.ceo for photos. A network filter or unavailable service may prevent a live result.

Students will practise

  • Finding the request, response and image URL.
  • Explaining how a tool supplies information to a program.
  • Separating a label in data from a visual observation.
  • Choosing “not enough information” when support is missing.

If live access is unavailable, use the labelled no-network teaching sample in the lab, or the illustrative URL on the worksheet. The teaching sample illustrates a beagle response without fetching a photograph. Neither is a fresh API result. Students do not need to enter personal information.

The lesson route

Predict. Observe. Explain.

  1. 01 5 min

    Predict the journey

    Before running the lab, ask: “What has to happen between asking for a dog and seeing its picture?” In pairs, sketch three boxes: request, service, response.

  2. 02 8 min

    Follow one request

    Run the lab once. Follow the moving marker and read the cards. Locate the API address, returned image URL and breed label. Ask which parts came from the service and which parts were written by the demo.

  3. 03 10 min

    Remove the clue

    Use the lab’s evidence exercise, or the worksheet below. Hide the whole image address, including the filename. Ask whether a text-only program can still name the breed. Discuss what new evidence would be needed.

  4. 04 7 min

    Make the call yourself

    Open the Dog API endpoint directly in a browser. Identify status and message in the JSON. Coding groups can run one example below. One or two requests per pair is enough; do not run a loop.

  5. 05 5 min

    Leave with an explanation

    Each student finishes: “The program knew ___ because ___. It could not establish ___ from that evidence.” Compare answers using the answer key.

Adapt to 30–40 minutes by shortening the code extension or giving pairs more discussion time. With one device, invite students to narrate each step while you operate the lab.

Student field notes

Where did the answer come from?

Name ________________________ Date ________________

  1. Predict

    What do you expect the API to send back: a picture, a picture’s address, or a written description? Explain your choice.

  2. Observe

    After one run, record the request address and one field from its response. What does that field tell you?

  3. Find the clue

    This is an illustrative URL, not a link to fetch:

    https://images.dog.ceo/breeds/beagle/example.jpg

    Circle the part that supplies a breed label. Does reading that label show that a program inspected the picture?

  4. Remove the clue

    Replace the whole image address with [address withheld]. A text-only program receives just that replacement, not the image. What can it now say about the breed? What additional evidence would help?

  5. Explain a limit

    “The program knew __________________ because __________________. It could not establish __________________ from that evidence.”

    Extension: if the API fails, what should the page show instead of pretending the request succeeded?

Dog API lab. simoneresearch.com/dog/. Jonathan Simone, Simone Systems Research. Worksheet text CC BY 4.0

For the discussion

Answer key & useful follow-ups

Look for a reason connected to evidence, rather than one exact phrase.

1–2: What does the API return?

The endpoint returns JSON. A successful response has status: "success" and a message containing an image URL. The browser makes a separate request to load that image. JSON text and image bytes are different things.

3: Did the program recognise the dog?

The beagle path segment supplies a label. Reading that label is not visual recognition. A label is also not a guarantee that the pictured dog has been classified correctly. Ask students what an image review would add.

4: What happens when the label disappears?

The response without its image address does not establish a breed. “Not enough information” is an appropriate answer. Inspecting image content, or receiving a trustworthy description with its source, would add evidence. Hiding one clue does not itself test a model’s ability to recognise images.

5: What should a helpful failure look like?

Show that the live request failed. Offer a retry or an explicitly labelled teaching sample. Keep the difference visible. A trace can help locate the failed step; it does not make an unsupported answer correct.

Optional coding extension

Call the API with JavaScript, curl or Python

Each example asks for one random image URL and prints data. None calls an AI model or requires an API key. Network errors are still possible.

JavaScript

Run in a browser developer console. Read the code first; follow your school’s device policy.

const response = await fetch('https://dog.ceo/api/breeds/image/random');
if (!response.ok) throw new Error('The request failed.');
const dog = await response.json();
if (dog.status !== 'success') throw new Error('No dog returned.');
console.log(dog.message);

curl

Run in a terminal with curl available. In Windows PowerShell, use curl.exe.

curl --fail --max-time 20 https://dog.ceo/api/breeds/image/random

Python 3

Save as dog.py and run with Python 3. Uses only the standard library.

import json
from urllib.request import urlopen

url = 'https://dog.ceo/api/breeds/image/random'
with urlopen(url, timeout=20) as response:
    dog = json.load(response)
if dog.get('status') != 'success':
    raise RuntimeError('No dog returned.')
print(dog['message'])

Next, identify the /breeds/ segment in the returned URL. Treat the following path segment as a label from the source, not the result of image analysis. See the Dog API documentation for other requests.

Words for what you just saw

Terms used in this lesson

API
An agreed way for one program to request data or an action from another. Here, the browser asks Dog API for an image address.
JSON
A text format for structured data. Named fields such as status and message make the response readable by a program.
Tool call
A request to run a function available to an agent. The function does the work, such as calling an API, then returns its result.
Trace
A record of steps and their inputs and outputs. It helps explain what happened; it does not certify that the answer is correct.
LangChain
A framework for connecting models, tools and agent behaviour. Read the official introduction.
LangGraph
A framework and runtime for organising stateful workflows, including steps controlled by code and steps involving models. The lab’s map illustrates this idea. Read the official introduction.
Langfuse
A tool for recording and inspecting AI application traces, including model requests and tool steps. The lab’s cards illustrate this kind of record; they are not live Langfuse traces. Read the official introduction.
File details on this page

Format, size and a short SHA-256 identifier, measured when this page was built.