Have you ever wondered how a Google map, or a YouTube video shows up on a third party website? The answer is through the magic of APIs. Well maybe it’s not magic, just some cool programming. APIs are the reason many of the programs we use can connect allowing us to have the seamless online user experience we have all come to expect.
So what is an Application Program Interface (API)?
A quick search of Google returns a definition of an API as “a set of routines, protocols, and tools for building software applications. An API specifies how software components should interact and APIs are used when programming graphical user interface (GUI) components…” Now this is a decent response for someone with a background in information systems but there are easier ways to explain what an API is, and how it is used.
In laymen’s terms an API allows one piece of software to “talk” to another. More specifically an API is a program that takes requests, tells a system what needs to be done, then returns a response. One of the best analogies I’ve heard to describe an API as a waiter at a restaurant. You need the waiter to communicate your order from you, at your table, to the kitchen where the food is made. The same is true with an API. The Waiter (the API) takes your order (the request) from your table to the kitchen (the system) and returns with your food (the response).
The most commonly used API is a REpresentational State Transfer or REST API for short. Google, Twitter, Facebook and YouTube all use REST APIs to allow third parties to access their systems. Usually a REST API works pretty much the same way a website does, you make a call from a client to a server and you get data back over the HTTP protocol. For example, if you would like to find the longitude and latitude of Baltimore you can make a call to Google Map’s API. Enter https://maps.googleapis.com/maps/api/geocode/json?address=baltimore&sensor=false into your browser (or click the link) and it will return data with the longitude and latitude on the page. Congratulations, you have now made an API request.
Now you might be wondering, “what types of request can you make using a REST API?” Here are the standard types of requests:
Get- is a method to read or retrieve data from a system (our Google Maps example)
Post- is a method to create new data in a system
Put- is a method to update/replace existing data in a system
Patch- is a method to updata/modifly existing data in a system
Delete- is a method to delete data in a system