You’ve heard these terms before. Perhaps your website makes use of an API, or your application consumes a Web Service. You may not be quite sure what these are and how they’re different, so here’s a quick guide for you.
API stands for Application Programming Interface. The word interface is the main idea here. An API defines how one piece of software (or website or mobile app) allows you to interact with it. While the definition is simple, the implementation can be extremely complex. Let’s consider an example.
Think about a website that allows you to sign up to receive items in the mail, like magazines or catalogs. The website will need to collect your mailing address, and it would be helpful if the website could make sure you entered a real, legitimate address. There are a number of applications that can check a US address to make sure it is a real address in a standardized form. The website can send the address you enter to one of those applications, and receive a response back. This interaction takes place through the address application’s API.
A Web Service is a specific type of API that is governed by a set of standards. Most Web Services use HTTP–the protocol most used on the World Wide Web–to send and receive information formatted in a certain way. There are lots of fancy concepts and words used to describe Web Services. The most important thing to remember is that Web Services use defined standards to govern how information is sent and received. You can send any kind of information you want, text or image files or encrypted customer data.
In our mailing list example, our website may subscribe to a Web Service that checks mailing addresses. The Web Service would have a request defined, with the information a website must include to get a good response back. This response would also be defined by the Web Service, so that the website making the request knows what it expects from the Service.
When you enter your mailing address, our website would use this definition to send the mailing address to the Web Service. The Web Service would check the address to make sure it is valid and would respond to the website to say “Yes, this is a real address” or “No, somebody is pranking us.”
Webhooks are another way to work through an API, governed by standards. These provide a “hook” that you can hang some actions on. In our mailing list example, perhaps we would like to get a notification in our online chat (say, AIM or Hangouts or Slack) whenever somebody signs up for a submission. We would use a single line of code on the website to say, “Put a webhook here, and give it this URL to post to.” Then, each time a subscriber submits their mailing address, the webhook will send that piece of information to the URL we give it.
APIs, Web Services, and Webhooks are being used to bring Internet capabilities into every part of our lives. We can use our phones to control the ever-increasing pool of Internet-connected products, like light bulbs and thermostats and home alarm systems. These interactions among disparate systems don’t have to be intimidating or scary–like lions and tigers and bears–instead, they allow us to add exciting new capabilities to websites and applications.