Mobile app version of vmapp.org
Login or Join
Angela700

: What’s the Difference Between a webhook and an API? Programmers who make a request to an API will then receive a response. For example, using Web API to send an email, you’d pass the email

@Angela700

Posted in: #Api #Data #Request #Webhook

Programmers who make a request to an API will then receive a response. For example, using Web API to send an email, you’d 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 you’d like to receive data. Whenever there’s 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.

10.03% popularity Vote Up Vote Down


Login to follow query

More posts by @Angela700

3 Comments

Sorted by latest first Latest Oldest Best

 

@Megan663

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.

10% popularity Vote Up Vote Down


 

@Ravi8258870

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.

10% popularity Vote Up Vote Down


 

@Radia820

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 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 sendgrid.com/blog/webhook-vs-api-whats-difference/

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme