What is an API, and how is it different from a webhook?
An API lets one program ask another for something. A webhook is the other app calling you. Here's how the two differ and when each gets used.
An API is a way for one program to ask another program for something. A webhook is a way for one program to announce something. Same road, opposite direction.
What an API is
Wikipedia calls an API a connection between computers or between computer programs.1 The letters stand for application programming interface. It's the set of requests an app is willing to answer.
You don't see it. An API is typically not visible to users, and it's used for machine-to-machine communication.1 A screen with buttons is for people. An API is for software.
Wikipedia gives a neat example with a weather sensor. A message sent to the sensor is an API call, and the weather report it sends back is an API response.1 Swap the sensor for your accounting app and the weather for an invoice list, and you've got the same pattern.
What a webhook does differently
With an API, your tool asks. With a webhook, the other app tells. Zapier describes webhooks as automated messages sent between apps.2 You don't send any request. You wait for the message to show up at your web address.
The two aren't rivals. They're often used together in one workflow.
Side by side
| API call | Webhook | |
|---|---|---|
| Who starts it | Your tool | The other app |
| Direction | You ask, it answers | It tells, you listen |
Make says webhooks usually act as instant triggers, unlike scheduled triggers, which periodically ask a given service for new data to be processed.3
Asking on a timer
Some apps don't offer webhooks. Make's help page says that if an app doesn't provide them, you can use polling triggers to check the service for new data.3 Polling just means asking again and again on a schedule.
Zapier has the same idea. If you want Zapier to make a GET request of an external URL to check for new entries, you use a Retrieve Poll trigger.2 A GET request is a simple "please send me what you've got" message.
So the choice is partly out of your hands. If the app you're connecting offers a webhook, you can use it. If not, asking on a timer may be the only option.
They can be the same tool
A single automation platform can work as both sides. n8n's Webhook node can receive data from outside. It can also return the data generated at the end of a workflow, which makes it useful for processing data and returning results, like an API endpoint.4
An endpoint is one specific address an API answers at. So in that case your own workflow is acting like a small API.
Where an AI tool fits
OpenAI's help centre says a key identifies your requests to its API.5 So when a workflow calls an AI service this way, a key is how the service knows who's asking. Guard it. The page on API keys explains why.
For the receiving side, start with What is a webhook?. The data that travels is covered in reading a webhook message.
Further reading and sources
- API, Wikipedia
- Trigger Zap workflows from webhooks, Zapier Help Center
- Webhooks, Make Help Center
- Webhook node, n8n Docs
- Best practices for API key safety, OpenAI Help Center