What is an API proxy?
© https://nodejs.org/en/

What is an API proxy?

Understand what an API proxy is and the benefits of using it.

ByMario Kandut

honey pot logo

Europe’s developer-focused job platform

Let companies apply to you

Developer-focused, salary and tech stack upfront.

Just one profile, no job applications!

This article explains a fundamental principle and is up-to-date.

In general, a proxy is something that acts as an agent or intermediary for something else. An API proxy provides an interface to developers for accessing backend services and sits between the application and the backend.

What is an API proxy?

💰 The Pragmatic Programmer: journey to mastery. 💰 One of the best books in software development, sold over 200,000 times.

An API proxy acts as a handler between a consumer and backend services. It is a shim (layer of code, which provides compatibility between different interfaces), which handles data transformations, security, routing, and more. It exposes an interface customized for the consumer (web, mobile,...), makes the API calls to the different backend services on behalf of the consumer.

Let's look at some examples:

  • A modern web application needs to get information from a legacy backend services that communicates in XML. Instead of making the web application calling the legacy API, an API proxy can handle this, and the web application can communicate with the shim JSON formatted. The API proxy will translate the JSON requests into XML and call the legacy API and then return and transform the payload and send it back to the web application.

  • Another example is when a web application has to make several API calls to get data from different backend services. This could be aggregated in an API proxy and only one call made to the API proxy from the web application, and the API proxy calls the other backend services.

An API proxy is an intermediary and helps a consumer get the data from backend services, without having to talk to all the services directly. It is a layer of abstraction between the consumer and the backend.

The API proxy pattern allows to expose a stable interface to the consumers. If a backend service changes, the adaptions can be made in the API proxy layer without having to change how the frontend consumes data. An API proxy also allows an easy implementation of caching of expensive calls to backend services and can improve performance. The downside is that latency between backend and frontend will be increased minimal.

Node API proxy graph Structure of an API Proxy

TL;DR

  • An API proxy is an interface that sits between frontend, and the backend services.
  • It decouples the frontend from implementation details of the backend.
  • Complex calls to multiple backend services can be simplified for the frontend.
  • Large and slow results from backend services can be cached.

Thanks for reading and if you have any questions, use the comment function or send me a message @mariokandut.

If you want to know more about Node, have a look at these Node Tutorials.

References (and Big thanks):

Sam Newman, HeyNode

More node articles:

Getting started with Webpack

How to list/debug npm packages?

How to specify a Node.js version

How to create a web server in Node.js

How to dynamically load ESM in CJS

How to convert a CJS module to an ESM

How to create a CJS module

How to stream to an HTTP response

How to handle binary data in Node.js?

How to use streams to ETL data?

How to connect streams with pipeline?

How to handle stream errors?

How to connect streams with pipe?

What Is a Node.js Stream?

Handling Errors in Node (asynchronous)

Handling Errors in Node.js (synchronous)

Introduction to errors in Node.js

Callback to promise-based functions

ETL: Load Data to Destination with Node.js

ETL: Transform Data with Node.js

ETL: Extract Data with Node.js

Event Emitters in Node.js

How to set up SSL locally with Node.js?

How to use async/await in Node.js

What is an API proxy?

How to make an API request in Node.js?

How does the Event Loop work in Node.js

How to wait for multiple Promises?

How to organize Node.js code

Understanding Promises in Node.js

How does the Node.js module system work?

Set up and test a .env file in Node

How to Use Environment Variables in Node

How to clean up node modules?

Restart a Node.js app automatically

How to update a Node dependency - NPM?

What are NPM scripts?

How to uninstall npm packages?

How to install npm packages?

How to create a package.json file?

What Is the Node.js ETL Pipeline?

What is data brokering in Node.js?

How to read and write JSON Files with Node.js?

What is package-lock.json?

How to install Node.js locally with nvm?

How to update Node.js?

How to check unused npm packages?

What is the Node.js fs module?

What is Semantic versioning?

The Basics of Package.json explained

How to patch an NPM dependency

What is NPM audit?

Beginner`s guide to NPM

Getting started with Node.js

Scroll to top ↑