Programmers who make a request to an API will then receive a response. For example, using Web API to send an email, youd pass the email contents with the request. If all goes well, you will receive a response declaring success.To use a webhook, you register a URL with the company providing the service. That URL is a place within your application that will accept the data and do something with it. In some cases, you can tell the provider the situations when youd like to receive data. Whenever theres something new, the webhook will send it to your URL.So, they are basically doing the same thing. My question is this: What is the difference between webhook and api? Not in the terms WEBHOOK IS ____ and API IS ______. I know what are they. I'm interested in key differences and when to use one, and when to use another.
Whats the Difference Between a webhook and an API?
api;data;request;webhook
The first and main difference between them is that with most APIs theres a request followed by a response. No request is required for a webhook, it just sends the data when its 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.