Application Programming Interface

Can someone please explain me how exactly does an API connect a front end and a back end


From the frontend you make a request (with AJAX for example). That request is handled by the backend (another computer), wich in the end of it’s logic will return a response (it may be an object for example). Then the frontend uses what comes with the response.

For example:

  url: '',
  data: { action: 'query', list: 'search', srsearch: $("input[name=Wikipedia]").val(), format: 'json' },
  dataType: 'jsonp',
  success: processResult

url is the url of the API we contact.
data is an object used to tell the API what we need.
dataType is the format in wich we want the response.
success has the value “processResult” wich is a function that uses the response of the API call.

Hope you find it useful!


So it is basically a programming language that it being used in a way to get data from the back end. The API itself isn’t another layer. Right??

It is not a programming language. Quoting wikipedia: “An Application Programming Interface (API) is a set of functions, procedures, methods or classes used by computer programs to request services from the operating system, software libraries or any other service providers running on the computer.”
It is an abstraction layer that let us get data without caring what’s “behind”. Someone creates an API, tells me what can I get and how, then I use it to get what I need.

Ohk I get it. Thanks for the answer