← VCE Software Development U4O1

What an API is

An application programming interface: a defined set of requests and responses that lets one program use the features or data of another program.

Understanding What an API is in VCE Software Development U4O1

What it does: requests.get(url) sends a request to the API, and the variable response stores what the API sends back. The contract says that sending a GET request with a city will return JSON. The caller does not need to know how the other program works inside. An API is an Application Programming Interface. It is how one program talks to another program. An API gives a program a defined way to ask for features or data from another program. It does not speed up the program. An endpoint is the address a program sends its request to, for example https://api.example.com/weather. The API contract sets out the rules: valid requests and the format of responses. The caller never sees or changes the internal code.

Common mistakes: The requests library has no fetch() function. A request to an API endpoint is made with requests.get(url), so the line should be response = requests.get(url). The module is called requests, with an s. Importing request causes a ModuleNotFoundError, so the program cannot send its request to the endpoint. It should be import requests.

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 115–124) and word search (Modules 115–171).

Take this worksheet further — free with Cloodit

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

Learning
Duo
What does API stand for?
Application Programming InterfaceAutomated Program Instruction
Matches
An API lets you open the other program's source code and change how it works
↓
An API does not give access to the other program's internal code. It only exposes defined requests and responses that you can use.
Applying
Meanings
Term
API
Meaning
An application programming interface: a defined set of requests and responses that lets one program use the features or data of another program.
Practice
def weather_api(endpoint):
Testing
Gaps
import
Check Answer
Spots
2url = "https://x.io/users"
3response = requests.fetch(url)

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

The 'Moose' badge — Tundra Champion, 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. What does API stand for?
A. Application Programming Interface ✓
B. Automated Program Instruction
An API is an Application Programming Interface. It is how one program talks to another program.
2. What is the main job of an API?
A. Makes a program run faster on any computer
B. Lets one program use the features or data of another program ✓
An API gives a program a defined way to ask for features or data from another program. It does not speed up the program.
3. Which is the correct order for an API interaction?
A. Your program sends a request, then the API sends back a response ✓
B. The API sends a response, then your program sends a request
Every API interaction starts with a request from the client program. The response comes back afterwards.
4. What is an endpoint?
A. The last line of code in a program
B. A specific URL where an API receives requests ✓
An endpoint is the address a program sends its request to, for example https://api.example.com/weather.
5. Why is an API described as a contract?
A. It defines which requests are allowed and what responses will be returned ✓
B. It lets the caller change the other program's source code
The API contract sets out the rules: valid requests and the format of responses. The caller never sees or changes the internal code.

Match the Pairs

API → An application programming interface: a defined set of requests and responses that lets one program use the features or data of another
https://api.example.com/weather → An endpoint: a specific address that a program sends a request to in order to use one feature or get one set of data
A request and response: your program asks an API for data, and the API sends an answer back → response = requests.get(url)
An API is a contract: it states what you must send and what you will get back, so both programs can rely on it → GET /weather?city=Melbourne returns JSON
An API lets you open the other program's source code and change how it works → An API does not give access to the other program's internal code. It only exposes defined requests and responses that you can use.
requests.get("weather") # sends a request to the endpoint → The endpoint is not a full address. An endpoint is a specific URL, such as https://api.example.com/weather, so the request cannot reach the API.

Key Term

API
An application programming interface: a defined set of requests and responses that lets one program use the features or data of another program.

Fill in the Blanks

1. import requests
Hint: Type the name of the library that lets Python send requests to a web API.
2. url = "https://api.example.com/weather" response = requests.get(url)
Hint: Type the variable that holds the endpoint address being requested.
3. response = requests.get(url)
Hint: Type the method that sends a request asking the API for data.
4. if response.status_code == 200: print("Request succeeded")
Hint: Type the response attribute that holds the number the API sends back to say whether the request worked.
5. response = requests.get(url) data = response.json()
Hint: Type the method that turns the API's response body into Python data.

Spot the Error

Question 1
A import requests
B url = "https://x.io/users"
C response = requests.fetch(url)
D print(response.status_code)
Line C — The requests library has no fetch() function. A request to an API endpoint is made with requests.get(url), so the line should be response = requests.get(url).
Question 2
A import request
B endpoint = "https://x.io/pets"
C reply = requests.get(endpoint)
D print(reply.status_code)
Line A — The module is called requests, with an s. Importing request causes a ModuleNotFoundError, so the program cannot send its request to the endpoint. It should be import requests.
Question 3
A response = requests.get[url]
B if response.status_code == 200:
C print("Request worked")
Line A — get is a function, so the endpoint URL must be passed in round brackets. Square brackets are for indexing. It should be response = requests.get(url).
Question 4
A import requests
B url = "https://x.io/weather
C reply = requests.get(url)
D print(reply.text)
Line B — The string holding the endpoint URL is missing its closing quote, which is a syntax error. It should be url = "https://x.io/weather".
Question 5
A import requests
B url = "https://x.io/pets"
C reply = requests.get(url)
D data = reply.json
E print(data["name"])
Line D — json is a method, so it needs brackets to run. Without them data holds the method itself and data["name"] fails. It should be data = reply.json().

Student with a class code? Join your class →