0%
Overview page background
HomeOverviewsWeb3 Tools
What is a webhook?

What is a webhook?

Written by Shray Jain

Brady Werkheiser headshot

Reviewed by Brady Werkheiser

Published on 2022-06-205 min read

Webhooks enable developers to facilitate real-time communication between two applications in an automated manner. As opposed to continuously polling servers for information, webhooks are quick, easy-to-set up, and are often perceived as a lightweight alternative to building out a full-fledged API service. 

Using the Alchemy Notify API, developers can push real-time notifications to users for critical events such as address activity, mined transactions, and other use cases. 

For example, building a decentralized application with real-time transaction notifications is made possible and made simpler using webhooks. Implementing webhooks significantly improves the end-user experience and eliminates the need to build a time-consuming and complicated notification system from the ground up. 

This article elaborates on what a webhook is, how it works, its numerous web3 notification use cases, and how to start using Web3 webhooks.

What is a webhook?

A webhook is an automated medium through which one application can push real-time data to another. Webhooks can only facilitate one-way communication between two services, are faster than polling endpoints, and require less development effort.

What is a webhook URL? 

A webhook URL is the application’s address where data is received from the sender application. Typically, webhooks are used to connect two disparate applications, where one is the “sender” and the other is the “subscriber” of event information. When an event occurs on the sender application, it sends that data to the subscriber application’s webhook URL. 

What is a Webhook endpoint? 

A webhook endpoint is the webhook URL that has been configured for the sender application to provide data to the subscriber application. In order for the sender application to provide data to the subscriber application, it needs a webhook URL to deliver the requested information.

In effect, a webhook URL is the endpoint and needs to be public for seamless flow of information between the applications. Once a request has been triggered and data has been parsed, the subscriber application can then send a callback message, with an HTTPS status code to inform receipt of data. 

What is a webhook API? 

As opposed to continuously polling an endpoint to determine whether a state change has occurred, webhooks provide information as soon as it becomes available. In other words, webhooks can be regarded as “reverse APIs” because communication is initiated by the program supplying the data rather than the one requesting it.

Just like a conventional API, information and functionality is shared between two software interfaces. By virtue of the efficiency and tangible benefit of employing webhooks, developers view the medium as an actionable, lightweight solution for real-time data updates and web3 notifications.

What is a webhook integration? 

A webhook integration allows developers to automate messages between one application and another using a unique URL. For instance, developers can utilize Zapier, a software tool that enables automation of repetitive tasks between two or more applications without needing to code new functionality. Without Zapier, users would not be notified and the response would just be another response, typically a JSON object.

Contrarily, integrating Zapier with Alchemy webhooks can lead to sharing Web3 data across a wide range of 3rd party applications like Discord, Twitter, and Slack. So when an on-chain event happens (e.g. new activity occurs in a tracked wallet), Zapier can send a message to a dedicated Slack channel, Discord server, or Twitter account. In effect, a service such as Zapier improves the communication loop and creates a more useful product for developers and users alike. 

Integrating Zapier with Alchemy webhooks is relatively simple and straightforward. In fact, developers do not require an excessive amount of tools to accomplish the integration, just an Alchemy account and a Zapier account. 

What do webhooks do?

Webhooks enable applications to share real-time data to other applications, boosting functionality. To help expedite Web3 application development, Alchemy’s Notify API—based on webhooks—assists users with things like monitoring address activity, mined transactions, and more on the Ethereum, Polygon, Optimism, and Arbitrum blockchain networks.

Developers can build functionality for four types of notifications using Alchemy Notify:

  • The mined transaction webhook can be used to notify your application anytime a transaction that has been sent through your API key is mined successfully. This notification can prove useful when it comes to informing customers the moment their transaction has been executed. 

  • A dropped transactions webhook is used to notify your application anytime a transaction sent through your API key gets dropped. 

  • A webhook can also be used to track all ETH, ERC20, and ERC721 transfer events for as many Ethereum addresses as a developer would like.

Webhooks can be used for multifaceted purposes to notify users of new activity or dApp updates.

Webhook Examples

As the Ethereum blockchain does not natively support notifications, there’s no way for a dApp user to stay up-to-date on transaction statuses without having to constantly refresh their application or checking etherscan. Overall, it’s a time-consuming process which discourages users from reusing the application again.

Now, using Alchemy Notify and Alchemy’s pending transaction WebSocket, users can track minded and pending ETH transactions seamlessly

The resulting outcome of the aforementioned walkthrough enables developers to send SMS notifications for any activity throughout the lifecycle of the transaction to their users. This leads to a superior user experience that can provide an edge in today’s competitive market. 

Why should web3 developers use webhooks?

Decentralized applications have become architecturally more complex as blockchain networks such as Ethereum have gained mainstream popularity. Yet, the end-user experience in the Web3 ecosystem still lags that of Web2.

One missing piece of Web3 UX infrastructure is real-time notifications. For instance, end-users want to know when their trades execute, when transactions fail, and when their auction bid has been accepted among other needs. 

Developers need to know inadequate support for webhooks could force their dApp users to abandon their service altogether for the previous reasons in addition to transaction anxiety and delayed confirmations. 

In general, setting-up real-time notifications into dApps has been a pain point for developers due to the complexity, time, and inevitable errors of building systems from scratch.

How do webhooks work?

Developers can consider webhook notifications to be similar to SMS notifications. The end-user that intends to send a message has your registered phone number, which acts as the address to deliver information. By subsequently responding to the message confirming that you have received it, you are then able to create a two-way communication system.

How to Call a Webhook

Calling a webhook requires a few inputs from the developer through a three-step process:

1. Developers identify the endpoint or webhook URL of the application that should be receiving data

2. The webhook URL needs to be incorporated into the application sending the data so that the payload and query variables can be parsed without encountering issues. 

3. Specifying the rules of the webhook that will ultimately trigger an event type notification to the end-user. 

Today, developers can set up webhooks from Alchemy's dashboard or programmatically. To practice calling a webhook in the context of a Web3 tutorial, learn how to build a whale alert bot in Telegram.

How long do webhooks take to work?

Ensuring a webhook is up-and-running takes limited time. In fact, developers can review this tutorial on how to set up a webhook server showcasing three simple steps to set up an Alchemy Notify webhook server using either a node-express configuration or a webhook server configuration built using python-django. 

Overall, installing, running, and locally testing the webhook server is low effort and requires only a few commands.

Start Using Webhooks in Your Web3 dApps

With Webhook support for Ethereum, Optimism, Arbitrum, and Polygon, web3 developers should evaluate the cases for using Alchemy Notify to improve the user experience of their decentralized applications.

With more builders and competition in the web3 space, user experience design is one important area where consumer-facing applications like wallets and dApps can differentiate themselves from their competitors.

Overview cards background graphic
Section background image

Build blockchain magic

Alchemy combines the most powerful web3 developer products and tools with resources, community and legendary support.

Get your API key