# Teach API testing with a 60-minute hands-on workshop

Use Fun API as a practice service for a classroom or team learning session. Learners can use the browser playground or a network client. Each learner should generate their own X-Sandbox-ID for network requests; the browser playground keeps its own local state. No Fun API signup is needed. These materials do not include a gradebook, certification or managed classroom service.

## 5 minutes: Introduce the request contract

Explain method, URL, query, headers, status and body. Distinguish browser simulation from the live /api service.

## 5 minutes: Prepare isolated clients

Choose browser sandbox or a network tool. For network calls, generate one UUID per learner and send it as X-Sandbox-ID. Use only the sample data.

## 10 minutes: Read and assert

Complete exercises 1 and 2. Ask learners to explain why the missing-resource test passes with a 404.

## 10 minutes: Filter and reject invalid input

Complete exercises 3 and 4. Check every item, and reject an invalid query value explicitly.

## 10 minutes: Handle unusual statuses

Complete exercise 5. Compare an expected training failure with an unexpected outage.

## 10 minutes: Revalidate a cached representation

Complete exercise 6 with a live network client. Preserve the ETag exactly and inspect the empty 304 body.

## 10 minutes: Review and reproduce

Learners exchange assertion descriptions or sanitized collections, rerun with their own sandbox, and explain one pitfall. Use the challenge page for further practice.

# Exercises and answer notes

## 1. Assert an existing resource

GET /api/friends/v1/characters/1. Expect 200, JSON, id = 1 and a nonempty name. Explain why checking only the status is incomplete.

https://funapi.dev/docs/friends#fr-get

## 2. Prove the missing case

GET /api/friends/v1/characters/999999. Expect 404 and error = Not Found. Keep a separate assertion from exercise 1.

https://funapi.dev/docs/friends#fr-get

## 3. Validate every filtered item

GET /api/pizza/v1/menu?vegetarian=true. Expect 200, nonempty data, total equal to data.length and vegetarian = true on every item.

https://funapi.dev/docs/pizza#pz-menu

## 4. Test the input boundary

GET /api/pizza/v1/menu?vegetarian=sometimes. Expect 400 and error = Bad Request. Compare with the valid true/false filter.

https://funapi.dev/docs/pizza#pz-menu

## 5. Recognize deliberate errors

GET /api/coffee/v1/teapot and GET /api/pizza/v1/oven/status. Expect 418 and 500 respectively. Explain why these requests are successful tests of intentional failures.

https://funapi.dev/testing/negative-testing

## 6. Revalidate with an ETag

GET /api/football/v1/standings, save ETag, then repeat in the same sandbox with If-None-Match. Expect 200 then 304, the same ETag and no second response body.

https://funapi.dev/learn/pytest
