APIs: programs working together — Computing, 11–13
An API is an agreed way for one program to ask another program for a service, without needing to know how that service is built inside.
A request window between programs
An API is like a service counter with a menu. Your program sends a request in the expected form, another program does the hidden work, and a response comes back. You use the counter without entering the kitchen, so an app can use maps, weather or payments without rebuilding those systems itself.
Why have an API?
Programs need to cooperate, but sharing every internal detail would make them fragile and difficult to update. An API sets a smaller agreement: these requests are allowed, these details are needed, and this is the shape of the answer. The idea grew from the problem of connecting separate systems while letting each team change its own code inside.
Asking for the weather
Imagine a weather app asking an API for Lisbon. First, it sends the place name and an agreed request such as “weather for Lisbon”. Next, the weather service checks its data. Then it returns values such as 18 °C and “rain”. Finally, the app puts those values on its own screen; it never needs to run the weather station itself.
“An API is the whole program”
A menu is not the whole restaurant, and an API is not the whole service behind it. This mistake is reasonable because you only see the requests and answers, not the hidden work. The API may offer only a few actions, reject a badly formed request, or limit how often you ask. The inside can change while the agreement stays the same.
Apps and online services
When a shopping app takes a card payment, a travel app shows a map, or a game displays a player’s score, APIs may connect the pieces. They also let a school project use a translation or timetable service. If you build a small app, an API can save months of work, but you still need to check its rules, privacy conditions and reliability.
Keep exploring
Other languages
Loading MyLeoNes™…