Coding · Grade 8
APIs with Controlled Mock Services
Learners discover how programs request data from other programs through APIs, using a local mock weather service so that no real network calls are made. They read requests, responses, status codes and JSON, parse JSON in Python, write code that checks status codes and missing fields with safe fallbacks and caching, and use APIs responsibly by protecting keys, minimising personal data and respecting limits.
- 4 lessons
- About 85 minutes
- Check what you learned: 8 questions
- Ways to answer: choose an answer, put code in order, trace code, highlight a text, match pairs and sort into groups
What learners will discover
- Explain API requests and responses, including endpoints, parameters, status codes and JSON bodies.
- Parse JSON text into Python values and use the resulting dictionaries and lists.
- Handle API failures robustly by checking status codes and fields, using fallbacks and caching to respect rate limits.
- Use APIs responsibly: protect keys, send minimal personal data, respect terms and limits, and test with mocks.
Lessons
-
What an API is 5 steps2 practiceabout 20 min
-
Using JSON data in Python 5 steps3 practiceabout 22 min
-
Handling errors and limits 5 steps3 practiceabout 20 min
-
Using APIs responsibly 4 steps2 practiceabout 18 min
-
Check what you learned 8 questions at the end
Keep exploring
Games to practice with
- Bug DetectiveA robot program almost works. Run it, spot the buggy block, and fix it.
- Sorting FactoryTurn a work order into if/else rules and watch the conveyor sort every item.
- Garden AutomationProgram a garden robot with sensor rules — then watch a whole day play out.
More 8th grade coding
- 8th Grade Coding Games4 games to play free
- 8th Grade Coding Worksheets10 printable worksheets
Guide for grown-ups
- How to start homeschooling: a step-by-step guide for familiesA guide for parents · 7 min read