Free tennis API exercises for Python and JavaScript classes
Live Tennis API publishes eight graded coding exercises for classes that work with a real JSON API. Each one comes in Python and JavaScript, with tests that run offline against recorded responses. The code is free to use and adapt under the MIT licence, and the live parts run on the free plan.
Open the exercises on GitLabRead the teacher guide on GitLab
What do students learn?
Students start by calling a health endpoint. By the end they have built a terminal scoreboard that polls live scores without running out of requests. They need to know functions, loops and dictionaries (or objects in JavaScript), and nothing else.
| Exercise | Students learn to | Level | Time |
|---|---|---|---|
| 1. First request | call an endpoint with no key, then with a key from the environment | Beginner | 30 min |
| 2. Read a score | turn player-major score arrays into a line such as "6-4 3-4, 30-15" | Beginner | 45 min |
| 3. Break points | write a pure function with careful edge cases | Intermediate | 40 min |
| 4. Filter and group | group live matches by tour and count them by tournament | Intermediate | 45 min |
| 5. Player search | handle zero, one and many search results | Intermediate | 45 min |
| 6. Rate limits and quota | respect a per-minute limit, retry a 429 and read your quota | Advanced | 60 min |
| 7. Errors | turn 401, 403 and 404 responses into messages people understand | Intermediate | 45 min |
| 8. Terminal scoreboard | poll live scores at a rate that fits the daily quota | Advanced | 90 min |
The teacher guide maps each exercise to these outcomes.
- Make an authenticated HTTP request from Python or JavaScript, with the secret kept out of the code.
- Read nested JSON with confidence, including arrays of arrays and fields that may be null.
- Write pure functions with clear edge cases, and test them with a table of inputs.
- Filter, group, sort and count records without changing the input.
- Handle zero, one and many results from a search.
- Explain the common HTTP error codes and turn each into a message a user can act on.
- Respect a rate limit, retry with backoff and stop when a quota runs out.
- Plan a request budget with arithmetic and build a polling loop that never overspends.
Do students need an API key?
Not for the tests. They replay recorded responses, so a student can finish every exercise with no network and no key. Exercises 2, 3 and 4 never touch the network at all, which suits a lab with no internet.
For the live runs, each student gets their own free key, with no card. The free plan allows 30 requests a minute and 100 a day. Never give the whole room one key, because thirty students on it would hit the minute limit straight away. The guide plans a typical student's day of requests so it fits.
How does it fit a course?
- Intro programming. Use exercises 2, 3 and 4 alone, as practice with lists, dictionaries and functions. Students never need a key.
- A web APIs module. Put the weight on 1, 5, 6 and 7, and use 8 as the assessed project.
- Three 2-hour sessions. Exercises 1 and 2 on requests and nested data. Then 3, 4 and 5 on functions, collections and search. Then 7 and 6 on errors and limits, and a start on 8.
How do I grade it?
Each exercise is worth 10 points. Six come from the tests and four from reading the code: two for correctness beyond the tests, two for clarity. The guide lists what earns the correctness points in each exercise, and the mistakes students make most often.
Worked solutions sit next to the starters. For graded work, give students a copy without the solutions folders. The GitLab pipeline then grades their starters, and goes green once every test in both languages passes. If you teach one language, delete the other job from the pipeline file.
Can I change the exercises?
Yes. The code is under the MIT licence, so you can copy, change and hand it out. The recorded responses are under CC BY 4.0, credited to Live Tennis API. The project's CITATION.cff file has the details if you cite the set in a syllabus or a paper.
Are you teaching with it?
We would like to hear how it went, what worked and what confused students. Email hello@livetennisapi.com. We never publish anything about a class without the teacher's consent. Problems with an exercise are welcome as issues on the GitLab project too.
Teaching or researching with match data instead? See the free academic dataset.
This page describes exercise set version 1.0.0, released 23 October 2026. The GitLab project always holds the latest version.