Where does the trip list live?
A phone app shows a list of school trips. The list does not live on the phone. It lives in a database (an organised store of data) on a server (a computer that shares data with other computers).
How does the app get it? It sends a request to an API (a door that lets one program ask another for data). In this lesson you see how that door works.
Key words
| Word | What it means | Example |
|---|---|---|
| Database | An organised store of data in tables. | A table of trips |
| API | A door that lets one program ask another program for data. | The trips API |
| Request | A message sent to an API to ask for something. | Give me all trips |
| Response | The answer an API sends back. | A list of trips |
| Endpoint | The web address of one kind of data on an API. | /trips |
| JSON | A text format for data that programs read easily. | {"place":"Zoo"} |
| Permission | A rule that says who may view data and who may change it. | Only a teacher may change marks |
The cells students fill in are left blank in this preview.
Quick check: the picture
Have a go
Quick check: the picture
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.
Request in, response out
A request asks for something at an address. The address is an endpoint, such as /trips.
The response is the answer. It is often written in JSON, a text format that programs read easily.
A request can ask to read data. It can also ask to change data.
One request and its response
| Part | Example | What it means |
|---|---|---|
| Request | Give me all trips | The app asks for data |
| Endpoint | /trips | The address of the trips data |
| Response | [{"place":"Zoo"},{"place":"Museum"}] | The answer, written in JSON |
| Another request | Add a trip called Park | This changes data, so permission is checked |
The cells students fill in are left blank in this preview.
Quick check: read the example
Have a go
Quick check: read the example
3 questionsYour answers are marked here and are not kept. A college account keeps every student’s marks.