API Mesh is an API Broker service combining multiple APIs into one endpoint. The goal? Simplifying API-related works, decreasing the development time and improving user experience. API Mesh supports API management and gateway API IO, which is easy to use in the case of microservices architecture because it can also support duplicates for multiple languages.
Adobe App Builder API Mesh is scalable, resilient, and flexible to help integrate APIs all over your organization. This article contains a brief overview of the parts that make up what it takes to get everything working.
Prerequisites :
End Point: Sublime text writer in Adobe developer account if you don't have one already.
Build a new Adobe I/O project in the Adobe I/O Console.
Install CLI: Execute the command below to install Adobe I/O (Command Line Interface):
npm install -g @adobe/aio-cli
Authenticate with your Adobe account to log into the CLI:
aio auth login
Create a new project: Change directory to your project and run:
aio app init
New Project: Log in to Adobe developer console, go to projects, and create a new project.
Add API Mesh: From your project, click 'Add API' and select the option to 'API Mesh'.
Attach Workspace to API Mesh: Select your project and add the service as API Mesh.
Now that we have included the API Mesh, let’s configure our prototyped application to consume it:
1. Create a mesh. Add a new file in the config folder (e.g., mesh.json) for your project.
2. Define APIs: Tell the mesh about which API you need to see in Mesh. This allows you to determine their endpoints, how request and response transforms are defined, and any helpers.
{
"apiMesh": {
"services": [
{
"serviceName": "Service1",
"basePath": "/service1",
"endpoints": [
{ "path": "/endpoint1", "method": "GET", "resolver": "resolver1" },
{ "path": "/endpoint2", "method": "POST", "resolver": "resolver2" }
]
}
]
},
"resolvers": {
"resolver1": {
"type": "http",
"target": "https://api.service1.com/endpoint1",
"requestTransformation": {
"headers": { "Authorization": "Bearer " + this.sessionAccess.getToken() }
}
},
"responseTransformation": {
"data": {
"map": [{ "id": "identifier", "name": "fullName" }]
}
}
}
}
Login: aio auth login
Create a new project: aio app init
Add an API: aio app add API
Deploy the project: aio app deploy
Start the application locally: aio app run
You will have to manage API keys and use OAuth2 for authorization. Formsuscita APIs are used from the public Internet or via VPNs. They may need different levels of security.
Generate an API key in the Adobe I/O Console and include it in your headers.
Implement secure authentication and token generation with Adobe’s OAuth2 Service.
Example 1: Simple GET Request
curl -X GET "https://api-mesh.example.com/resource" -H "Authorization: Bearer {token}"
$ curl -X POST "https://api-mesh.example.com/resource" --header "Authorization: Bearer {token}" --data '{"key": value }'