What is a Webhook?

Asked

Viewed 582 times

17

I saw some questions here that talk about the term Webhook. I would like to know better what that term is in programming.

  • 1

    Example: https://answall.com/q/44760/101

  • 1

    https://i.stack.Imgur.com/nB3M0.png

5 answers

24


Webhooks are basically a means of communication between your applications. With them, an application is able to send data to other applications. Thus, webhooks send data through the event of a specific event, usually in real time. In short, an authentic callback established through the HTTP protocol.

The application that implemented webhook will send HTTP requests to applications that have signed up. For this reason, they are also called "web callbacks" or "Reverse API".

Like the webhook will send an HTTP request to other applications, if your application will "receive" the data, it must be prepared to receive and interpret the data, which is usually sent under the POST method with a payload in JSON. The receiving application will thus configure a endpoint HTTP (usually in the POST method), to receive the data.

Diagrama de Webhook

Above we have a simple diagram to illustrate how a webhook works. In this case, "Twitter Server" is the application that will send the webhooks and "Your Server" is the application that will receive them. This way, through the event of events on Twitter, your application will receive HTTP requests (webhooks), sent by Twitter. Therefore, the application that will receive these callbacks must be prepared to handle and interpret such requests.

There are also ways to authenticate in the middle of webhooks. As the application that will receive the data should maintain a endpoint to receive the data of the application that will send the webhook, people with bad intentions can use this endpoint to send false information. This way, some means of authentication can be configured between the two applications to avoid this problem. Among the most common means of authentication, can be cited:

  • Creating a white list with preconfigured Ips;
  • Authentication HTTP Basic;
  • Miscellaneous tokens, which can be included in HTTP headers. Github, for example, uses this technique.

Webhook API

Many people confuse webhooks with Apis. However, although they provide data to a customer, they do so in different ways. Basically, a webhook will send the data to the applications inscribed in real time (in "push"), while an API will send the data when requested by the client.

In addition, the purpose of the Apis is to provide an extensive amount of tools to customers, such as a CRUD. Webhooks, on the other hand, most often have the function of notifying the event of an event, and can also send data related to the event. There is an article in English that elaborates much more these differences.

Reference

Resources I used to elaborate this response:

8

A Webhook is a way to allow an action to be executed after an event.

It is usually used to allow external applications to utilize the data of an event at the exact moment it happens.

Examples of this would be the integration of github with Slack, trello with Discord, and so on.

The concept is summarized in: - A party that will provide such data, and therefore needs to allow "listeners" to be registered for the selected events - Another party that will know how to use this information as desired

-2

Webhook is a form of receiving information, and it is only passed when an event occurs. In practice, it is a form of information exchange between two systems, but only when there is actually information to be passed on. It’s a practical way for an app or system to provide real-time information.

You may also know webhook as an HTTP callback.

At this link here you can find more details even on how to create or implement a webhook.

-5

A webhook in web development is a method of enlarging or changing the behavior of a web page, or web application, with custom callbacks.

-5

Browser other questions tagged

You are not signed in. Login or sign up in order to post.