Calling a web API with requests.get()
Sends a request to a web API endpoint at the given URL and returns a response object. Needs import requests. Check response.status_code (200 means success) before using the data.
Understanding Calling a web API with requests.get() in VCE Software Development U4O1
What it does: The params dictionary is added to the URL as a query string, so the API knows which data to send back. response.status_code holds the result code of the request. A value of 200 means success, so the program can safely use the data. requests.get(url) sends a GET request to the URL and returns a response object. There is no requests.send() function. The library is called requests (with an s). You import it once, then call requests.get(url) in your code. 200 means OK, the request worked. 404 means the resource was not found. Parameters start after a ? in the URL. Extra parameters are then joined with &.
Common mistakes: The library is called requests, with an s. 'import request' causes a ModuleNotFoundError. It should be 'import requests'. The URL is text, so it must be wrapped in quotes. Without them Python raises a syntax error. It should be url = "https://api.x.com/v1".
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.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
requests.get(url)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →