Codele / How software is built
APIs and JSON
A weather app does not know the weather. It asks a weather service, and the service answers in a tidy written style. Pick a city and watch the question and the answer.
- An API is a menu of things one program may ask another program for.
- A request names what you want. The service sends back a reply.
- JSON writes the reply as names and values, like a dictionary. Every language can read it.
- You read one field by its name. Fields you do not ask for are ignored.
- Real apps send the request across the internet. Here the answer sits in a dictionary so you can see the reading part.
Loading the playable lesson…