en

Mulesoft: How to build an API with its API Designer

August 19, 2022

Tags: Technologies, Tech Trends

mulesoft

 

The integration of platforms and systems is an increasingly present need in companies, as they seek to optimize their processes and facilitate equipment access to systems. And in this task Mulesoft has been the perfect ally for many companies today.

 

With Mulesoft, companies can connect everything and empower everyone in one team. "Mulesoft's mission is to help organizations change and innovate faster by making it easier to connect applications, data and devices around the world," they explain in an article on the Expanded Ramblings portal.

 

All this connectivity is possible thanks to the Mulesoft and Anypoint Platform APIs, through which more than 1,200 companies in the world have been able to connect their applications and systems.

 

What is an API

 

Mulesoft is one of several tools that allow developer to build their own API from scratch with a tool called API Designer. What does an API allow? A BBVA API Market article defines it perfectly: An API “facilitates the exchange of messages or data. A set of functions and procedures that a library provides for use by other software as an abstraction layer, a space for accessing and exchanging additional information on top. So one uses the other's information while remaining independent."

 

How to build an API with Mulesoft API Designer

 

The first thing to build an API with the Mulesoft API Desginer tool is to sign up and create a free Anypoint Platform account. For this example, we'll create an integration that pulls a list of contacts from our internal database and uploads them as leads to Salesforce.

 

mulesoft

 

Next, you need to create the API specification. To achieve this, navigate to the Design Center option, there click on the Create button and select Create API Specification. Next, you put the name of the new API, then select the Visual Editor. The visual editor is an intuitive visual interface to create your API specification scaffolding without any coding!

 

software development

 

On the official Mulesoft page they explain “When you click the Create Specification button, you will be taken to the Design Center, which will display the API Summary page. The API specification scaffolding, which is exported in a language called RAML, is on the right side of the screen. For our first API, insert a Title, Version, Protocol, and Description. Make sure you accept HTTP and HTTPS requests and set our API to version 1.”

 

The next step would be to create a data type, this information will be added to the API RAM file. When the data type is created, the following four properties are added: FirstName, LastName, Email, and Company. You need to make sure that each attribute is defined by a thread, then go to the example window and define the JSON payload.

 

Now, a new resource, also known as an API Endpoint, needs to be created. They explain “Click the Resources tab on the left side of the API Summary page and click the plus button to create a new resource. Give our new resource /contacts a name that will define our endpoint URL for our app to also send HTTP requests.”

 

In the summary tab the name and description of the API is added. In the Responses tab, tap Add Responses and add the HTTP Status 200 – OK code. “Click the Add Body button and specify that the media type is application/json and the Type is Array. Then click the expand icon and select the type as the Data Type we just created called Contacts”.

 

This is all you need to create an API from scratch with the Mulesoft API Designer tool.

 

We recommend you on video