What’s the Difference Between a webhook and an API?
The first and main difference between them is that with most APIs there’s a request followed by a response. No request is required for a webhook, it just sends the data when it’s available.
Simple view:
The API is an interface to your data on example.com. The API is used from your server to the example.com platform and can be used to List, Create, Edit or Delete items.
Webhooks are automated calls from example.com to your server triggered when a specific event happens in example.com. For example, when a task is completed and you want to know about it in real time we'll make a POST request to the URL you have registered for the EVENT.COMPLETED webhook in your example account.
So, in a nutshell: The API is where you tell example.com things and Webhooks is where example.com tell you things.
Looking more in depth:
SaaS is a concept - the idea of Software that exists in the cloud and the client is generally a browser. A SaaS application is defined by the functions it can provide to a user (for example Salesforce provides a database that can be used to store customer information) the functions available are determined by the purpose of the application (ie: CRM, Email Blaster, CMS, etc.).
An API is a way for SaaS applications to be connected with other applications via a common communication method (ReST, SOAP, JSON, etc). An API cannot speak directly to another API. An API can be used by a coded application or middleware that acts as a bridge between two API's and runs the thread of execution. For example - both NetSuite and Salesforce have a SOAP API, but for them to communicate - you'd want to use middleware software that can interact with both systems and be configured to pull new contact records through Salesforce's API and push new records to NetSuite through it's API every hour.
Webhooks is another communication protocol for SaaS applications that allows for communication between applications, but simply using HTTP POSTS to control the thread of execution. Webhooks allow an application to speak directly to one another, without using middleware. For example - when you submit a form to WuFoo, it can be set up to initiate an webhooks HTTP POST to another service and pass over some field values from the form submission. Webhooks can also be used in conjunction with an API - for example after the webhook notifies the other application something to happened to record id X, that application could use an API to communicate with the service to check the new field values or modify a status of a record.
It is difficult to have an API or webhooks without having a SaaS application. However, you can easily have a SaaS application that doesn't use webhooks or a (public)API. Similarly, depending on the functions of your SaaS application, you may choose to use webhooks OR an API.
API is doing stuff when you ask it to, while Webhook does stuff on it's own when certain criteria match.
So, in a nutshell: The API is where you tell us things and Webhooks is where we tell you things.
via http://apidocs.teamwork.com/article/466-whats-the-difference-between-the-api-and-webhooks
Whenever there’s something new, the webhook will send it to your URL.
via https://sendgrid.com/blog/webhook-vs-api-whats-difference/
I'll illustrate this with a concrete example: Credit card payments.
When your site wants to charge a credit card, you call an API at your credit card processor. The credit card processor then charges the credit card returns a success or failure status to that API call.
The credit card processor may need some way of updating your site about this transaction later. For example, the transaction may be reversed next week. Your credit card processor could just send you an email about this. Another way of dealing with it is webhooks. You tell your credit card processor a URL on your site that they can hit and send you data. When the transaction is reversed, a credit card processor that supports web hooks will contact your site at the URL you provide and send you data in machine readable format that you can parse and have your web application deal with automatically.
A webhook is a callback mechanism for an API. You basically implement an API for asynchronous callbacks in conjunction with an API that you are calling.