← QCE Digital Solutions Unit 4

REST architecture

A web API style where data is treated as resources, each with its own URL, accessed using standard HTTP requests. Each request is stateless, so the server remembers nothing between requests.

Understanding REST architecture in QCE Digital Solutions Unit 4

What it does: The URL names the resource (the results of student 42). In REST, the address identifies the data rather than an action. The client code only sends a standard HTTP request and uses the response. It does not know how the server stores or finds the data. A stateless server keeps no memory of earlier requests. Any needed details, such as an API key or ID, must be sent again. With no stored client state, requests can be shared across many servers, which makes the service easier to scale. REST URLs name resources (nouns), while the HTTP method gives the action. Putting verbs in the URL breaks this style.

Common mistakes: The requests library has no fetch() function. To read a resource from a REST API you send a GET request, so the line should be r = requests.get(url). REST URLs name a resource (a noun) and the HTTP method is the action. A verb like getOrder in the URL breaks this. It should be GET /orders/12.

Class: _____________________  ·  Name: _____________________  ·  Date: _________

Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.

This module's key terms are also in a printable crossword (Modules 89–125) and word search (Modules 17–125).

Take this worksheet further — free with Cloodit

Each concept is reinforced from every angle — learned, then applied, then tested.

Learning
Duo
In REST, what does a URL such as /students/12 identify?
A resource (the student with ID 12)An action the server must run
Matches
GET /getStudent?action=fetch&id=42
↓
The URL describes an action instead of a resource. REST should use a resource URL like /students/42 and let the HTTP method (GET) show the action.
Applying
Meanings
Term
REST
Meaning
A web API style where data is treated as resources, each with its own URL, accessed using standard HTTP requests. Each request is stateless, so the server remembers nothing between requests.
Practice
GET /api/students/7 HTTP/1.1
Testing
Gaps
response = requests.(url)
Check Answer
Spots
2url = "http://api.co/items/3"
3r = requests.fetch(url)

Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.

The 'Angelfish' badge — Reef Perfectionist, one of Cloodit's 106 collectible badges
Students earn collectable badges

Over 100 of them, across seven natural biomes.

Study Buddy
Students build a real study resource

Turns their work into revision material ready for Flash Cards and Exam study.

Diamond Dash — one of Cloodit's live, competitive Sprint games
Students lock in with Sprints

Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.

A Cloodit certificate of achievement, ready to personalise and print
Custom printable certificates

Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.

Quick Questions

1. In REST, what does a URL such as /students/12 identify?
A. A resource (the student with ID 12) ✓
B. An action the server must run
REST treats data as resources. Each resource has its own URL, and the HTTP method says what to do with it.
2. Which statement describes a stateless REST request?
A. Each request carries everything the server needs to process it ✓
B. The server remembers earlier requests from the same client
Stateless means the server stores nothing about the client between requests, so every request must be complete by itself.
3. Which URL is better REST design for fetching one product?
A. GET /getProductNumberFive
B. GET /products/5 ✓
REST URLs name a resource (a noun like products). The HTTP method GET is the action, so the URL doesn't need a verb.
4. A client sends a second request to a REST API. What can the server assume about the first request?
A. The client is the same one that asked before and wants a related answer
B. Nothing, because each request stands alone ✓
A stateless server keeps no memory of earlier requests. Any needed details, such as an API key or ID, must be sent again.
5. Which describes client-server separation in REST?
A. The front-end and the server can change independently as long as the API stays the same ✓
B. The client must know how the server stores its database
The client only needs the URLs and the data format. How the server stores or processes data is hidden, so each side can be updated separately.

Match the Pairs

GET /students/42 → Asks the server for the resource that has the URL /students/42, using a standard HTTP method
GET /orders/7 Authorization: Bearer abc123 → A stateless request that carries everything the server needs, including the credentials, so the server remembers nothing from earlier requests
Resources are identified by URLs, so each item of data gets its own address → https://api.school.edu/students/42/results
Client-server separation: the client asks for data and the server sends it back, with neither depending on how the other works internally → response = requests.get("https://api.school.edu/students/42")
GET /getStudent?action=fetch&id=42 → The URL describes an action instead of a resource. REST should use a resource URL like /students/42 and let the HTTP method (GET) show the action.
GET /next-page (server uses its memory of the last page sent) → The server relies on remembered state from an earlier request, so the request is not stateless. The request should include the page number, such as /items?page=3.

Key Term

REST
A web API style where data is treated as resources, each with its own URL, accessed using standard HTTP requests. Each request is stateless, so the server remembers nothing between requests.

Fill in the Blanks

1. url = "https://api.school.com/students/7" response = requests.get(url)
Hint: Type the requests function that reads the resource at this URL.
2. GET /students/7 HTTP/1.1 Host: api.school.com
Hint: Type the HTTP method that asks the server for the resource at this path.
3. token = "abc123" headers = {"Authorization": token}
Hint: Type the variable from line 1. Each stateless request must carry its own credentials.
4. response = requests.get(url) data = response.json()
Hint: Type the method that turns the data the server sends back into a Python dictionary.
5. body = {"name": "Zoe"} requests.post(url, json=body)
Hint: Type the requests function that asks the server to create a new resource.

Spot the Error

Question 1
A import requests
B url = "http://api.co/items/3"
C r = requests.fetch(url)
D print(r.status_code)
Line C — The requests library has no fetch() function. To read a resource from a REST API you send a GET request, so the line should be r = requests.get(url).
Question 2
A GET /users
B GET /users/7
C GET /users/7/orders
D GET /getOrder?id=12
Line D — REST URLs name a resource (a noun) and the HTTP method is the action. A verb like getOrder in the URL breaks this. It should be GET /orders/12.
Question 3
A U = "http://api.co/me"
B h = {"Authorization": "abc"}
C r = requests.get(U)
D print(r.status_code)
Line C — REST requests are stateless, so the server does not remember who you are from an earlier request. The credentials must be sent with every request: requests.get(U, headers=h).
Question 4
A url = "http://api.co/users/7"
B d = {"house": "Blue"}
C r = requests.get(url, json=d)
D print(r.status_code)
Line C — GET only reads a resource. To update an existing resource at its URL you send a PUT request: requests.put(url, json=d).
Question 5
A import requests
B url = "http://api.co/users"
C r = requests.get(url)
D for u in r.json:
E print(u["name"])
Line D — json is a method of the response, so it must be called with brackets. The server sends the resource as JSON and the client reads it with r.json().

Student with a class code? Join your class →