Software
Application Programming Interface (API)
If user interfaces let us interact with a computer, how does a computer interact with another computer?
Good question!
Application programming interface (API)
Computers and software use application programming interfaces or APIs to connect. An API is a way for a computer to request data and then receive data back in a standardised form that it can understand.
We use APIs all the time – when you scroll through your Instagram feed, the mobile app makes API calls (requests) to Instagram’s servers, asking for the details of new images and videos to display within the feed.
Another common example is when you try to book a flight using a service like Expedia. After filling in your travel details (location, dates, number of people traveling etc) Expedia will make API calls at all the major airlines to see whether any seats are available on the selected days. The airlines will send back API responses to Expedia containing prices, departure times etc, who will use the information to generate a results page for you containing all of the available flight options.
Another way to describe APIs is via our favourite analogy, the restaurant.
Imagine you are looking at a menu and deciding what to choose. The goal is to get your food choice to the kitchen so they can make the meal. We could ask customers to go up to the window and start talking directly with the chefs and cooks, but that wouldn’t be very efficient.
Instead, a waiter acts as an interface between the customer and the kitchen, taking the customer’s request (“I think I’d like a burger. Can you make sure it’s cooked through? And maybe take out the cheese. Also, would it be possible to add some mayonnaise?”) and presenting it to the kitchen staff in a systematic way (“Burger, well-done, no cheese, add mayo”). The waiter can then translate the kitchen’s response (“F$*@!!!”) back to the customer (“Yes, that will be fine.”).
APIs can be private (used to connect systems within a business) or public (available for anyone to use, for example, a developer who wants to connect their app to another application).
JSON
When an API sends a response, it is commonly a JSON (JavaScript Object Notation) file. JSON is a standard file format that allows data to be transmitted in a structured, human-readable format.
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
While it may have “JavaScript” in the name, most modern programming languages can create and read JSON.