Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a Callback API?

Tags:

callback

api

I know what a Callback is, and I know what an API is. But what, exactly, defines a callback API? How is it implemented? How does it differ from REST APIs for example? To narrow it down, let's say callback APIs in NodeJS.

And are we talking about the client-side API, or the server-side API?

For a client-side API I could guess something like this:

  1. You make an API call to some url.
  2. You receive a response
  3. A callback function is called with the response as its arguments

This callback function is implemented in client-side, and you just pass the callback to the service function which actually makes the API call.

What about server side callback API?

like image 457
Ville Miekk-oja Avatar asked Aug 09 '16 14:08

Ville Miekk-oja


1 Answers

The technical difference between a Service API and a Callback API is only in name and is determined by who dictates/defines the API.

A Service API is defined by the service providing the API.

e.g. When a Service API is called, the caller must conform its request and handle the response based to what the service API offers.

A Callback API is defined by the service calling the API. (Also referred to as a Webhook or Reverse API)

e.g. When a Callback API is called, the responder must handle the request and provide a response that conforms to what the caller expects.

like image 188
Ben White Avatar answered Nov 07 '22 17:11

Ben White