Webhook vs. API—what’s the distinction? As you turn into acquainted with SendGrid’s companies, and even these of many Internet corporations, you’ll see the time period “API” used so much. Increasingly, you might also see somebody point out a “webhook.”
At SendGrid, we’ve consciously made a distinction between the two in our documentation and any time we write or talk about our seven companies for simplifying email. Here’s how we break down the variations between webhooks and APIs.
Webhook vs API
What is an API?
API stands for Application Programming Interface, however what does that actually imply? Rather than what it’s, I discover it simpler to speak about what APIs allow. APIs can share knowledge or performance. For instance, you would possibly use a locations API to lookup eating places by location or identify, pulling out a number of knowledge about every place. Then you would possibly mix that with a mapping API, utilizing it as an interface for displaying your knowledge.
Programmers who make a request to an API will then obtain a response. For instance, utilizing our Web API to ship an email, you’d go the email contents with the request. If all goes properly, you’ll obtain a response declaring success.
What is a Webhook?
Sometimes individuals name webhooks reverse APIs, however maybe extra precisely a webhook permits you to skip a step. With most APIs there’s a request adopted by a response. No request is required for a webhook, it simply sends the knowledge when it’s obtainable.
To use a webhook, you register a URL with the firm offering the service. That URL is a spot inside your software that may settle for the knowledge and do one thing with it. In some instances, you may inform the supplier the conditions while you’d prefer to obtain knowledge. Whenever there’s one thing new, the webhook will ship it to your URL.
“Call Me When He’s Warmed Up”
Baseball managers may actually use webhooks. As the sport progresses, they usually wish to change pitchers. To do that requires the new pitcher to first heat up in the bullpen, which is often over 300 toes from the crew’s dugout. If you watch baseball on tv, you’ll usually see the supervisor decide up a telephone in the dugout. He’s making a name to the bullpen to verify on the new pitcher.
- “Is he warmed up yet?”
- “Not yet”
Then he hangs up the telephone. In a couple of minutes, he’ll must name once more. Programmers would name this polling and it’s process-intensive for either side. A webhook permits you to say, “call me when he’s warmed up.”
Examples of Webhooks vs APIs
SendGrid has two distinct webhooks associated to every route that email flows:
- Event Webhook gives knowledge about the emails you ship, equivalent to bounces and when the recipient clicks a hyperlink.
- Inbound Parse Webhook permits your software to obtain email as quickly as a message is available in.
Some non-SendGrid webhooks:
Get began with webhooks
Now, you already know all the variations between a webhook vs API.
Now it’s time to start out doing one thing with these webhooks. Here are 4 issues you are able to do with webhooks, together with testing them in your native machine or connecting them to different companies.