eli5 The difference between an API and a webhook?

266 views

I am having a little difficulty in understanding what are APIs and how do they work. I have heard about them a lot like REST APIs but don’t understand what they are. I am also confused about webhooks and web sockets. I am not from computer science background.

In: 14

4 Answers

Anonymous 0 Comments

Very quick explanation:

An API is an interface that the maintainer of a service / module exposes to the outside world so that they can interact with said service / module.

So for instance, Reddit has an API, and you can request things like the list of comments on a specific post based on its unique ID.

The definition of a webhook is a little more broad because it’s used a little more liberally. Slack for instance used to call webhooks endpoints that you could hit to write messages (as yourself) in a specific slack room. This is, for all intent and purposes, just an API call.

Another use for the word is for instance a functionality offered by PagerDuty (an incident response provider, that send alerts to people when something goes wrong). In this case, a webhook is something you can configure to trigger API calls so that every time something happens (say any time someone resolves an incident in PagerDuty), PD makes an API call to the endpoint you provided them. This can be used to automatically update a status page on your website for instance. This effectively becomes a notification pipeline. You would need to write a service that is able to receive these API calls, and act on them.

You are viewing 1 out of 4 answers, click here to view all answers.