API Proxy using MuleSoft

Before diving deep into implementation, let's understand proxy in simple terms.

Proxy

I am sure a lot of us might have come across the word proxy(especially in college days 😁)

Proxy means - a person authorized to act for another.

In computer networking, A proxy server is a computer system or router that functions as a relay between client and server.

Proxy relaying messages between Alice and Bob

API Proxies

Clients, who want to use your backend services can use an API proxy as their interface while making REST calls. Instead of directly accessing the backend services, they use an Edge API proxy that acts as a relay.

API Proxy

Now let us see how we can implement API Proxy in Mule.

We will proxy a well-known free fake REST API service called {JSON} Placeholder.

There are multiple ways of proxying in Mule.  I will use the RAML-based approach which I feel is cleaner in terms of documentation of the API.

Usually, the backend services don't have any API documentation. Thus, creating a RAML or OAS specs can help clients consuming the API, understand the various endpoints and their operations.

Create a RAML for JSON placeholder API.
  • Go to the Design Center and create a new API spec
  • Deploy the spec to the Exchange

The API spec can be found here. I am using only the posts endpoint of the JSON placeholder for this demo.


Add API in API Manager
  • Select Manage API from the Exchange
  • Add the details of the published API

  • Add Deploy configuration
  • Check Runtime Manager for deployment status
  • Deployment complete

Now, we can call the JSON placeholder APIs over the Mule proxy API

Calling /posts

What else can be done with this proxy ?

Proxy opens a lot of options in terms of security, logging, etc.

For more details on what Gateway and proxies offer, check this previous blog:

API Gateway
What are the benefits of API Gateway?

Hope you like it. Cheers.

Tirthankar Kundu

Tirthankar Kundu