Unlike traditional systems where one system (subject) keeps polling another system (observer) for some data, webhooks allow the observer to automatically push data into the subject's system whenever an event occurs.
This eliminates the need for constant monitoring by the subject. Webhooks operate entirely on the Internet and therefore all communication between systems must take place in the form of HTTP messages.
Webhooks rely on the presence of static URLs pointing to APIs in the subject's system that need to be notified when an event occurs in the observer's system. An example of this would be a web app designed to collect and manage all orders placed on a user's Amazon account. In this scenario, Amazon acts as the observer and the Custom Order Management Webapp acts as the subject.
Instead of having the custom webapp periodically call the Amazon APIs to check for an order created, a webhook created in the custom webapp would allow Amazon to automatically submit an order newly created in the webapp via a registered URL. Therefore, to enable the use of webhooks, the subject must have designated URLs that accept event notifications from the observer. This reduces a significant load on the object since HTTP calls are made between the two parties only when an event occurs.
Once the subject's webhook is called by the observer, the subject can take the appropriate action with this newly submitted data. Typically, webhooks are done via POST requests to a specific URL. POST requests let you send additional information to the object. Additionally, it can also be used to identify among a number of various possible events instead of creating separate webhook URLs for each event.
To implement inbound webhooks on your application, you need to perform the following basic steps:
Both webhooks and APIs have the goal of establishing communication between applications. However, there are some distinct advantages and disadvantages of using Webhooks over APIs to achieve application integration.
Webhooks tend to be better solutions if the following points are more relevant to the implemented system:
Using the API should be preferred over webhooks in some other situations.
The important things to consider for using APIs on Webhooks are:
To deal with the possibility of losing data sent from a server when the webhook goes offline, you can use an event messaging queue to archive those calls. Examples of platforms that provide such functionality include Rabbit MQ o Amazon's Simple Queue Service (SQS). Both are designed to act as intermediary messaging storage facilities that avoid the possibility of missing a webhook call.
Ercole Palmeri
Developing fine motor skills through coloring prepares children for more complex skills like writing. To color…
The naval sector is a true global economic power, which has navigated towards a 150 billion market...
Last Monday, the Financial Times announced a deal with OpenAI. FT licenses its world-class journalism…
Millions of people pay for streaming services, paying monthly subscription fees. It is common opinion that you…