API Lifecycle Management in Anypoint Platform
Let this post guide you through the steps of the API lifecycle in Anypoint Studio's API Manager, from creation to deployment.
Join the DZone community and get the full member experience.Join For Free
Anypoint Platform provides a feature called API Manager, by means of which one can manage APIs easily. In this article, I am going to discuss the lifecycle of an API from its creation.
In the next sections, each step will be discussed in detail.
API Manager - Create the API and Portal
API Manager is the entry point for API development. Here we define the API using RAML. In this example, we are going to create a simple Experience Layer API. This API will be exposed at the end for public consumption. Take a look at the sample RAML we will be working throughout the example.
After defining the API, we can create a simple API Portal. This is the screenshot of our Portal,
Anypoint Studio - Implementation of API
After defining the API in API Manager, we will implement the API. Here goes the actual code of the implementation. For simplicity, I am not going to explain the implementation part of the API. Let's suppose that the name of the application where we are implementing the API is experience-api-mobile.
Cloudhub - Publish
After implementing the API, we will publish it in Cloudhub. At this point, we have our application up and running. Let's suppose that the URI of the service is http://experience-api-mobile.cloudhub.io/.
Now we go back to API Manager to expose our API for public consumption. Also, we are going to apply security policies to it.
API Manager - Create & Deploy Proxy
Now we will create an API Proxy for the API, as shown below:
Note that in the Implementation URI , we are referring to the actual implementation of the service which is already up and running in Cloudhub.
Now let's deploy the proxy. While deploying the proxy to Cloudhub, put a different name for the application. After deploying the proxy, the URI will be http://mobile-api-proxy.cloudhub.io.
Why do we do this? In fact, the proxy serves as kind of a security shield against our actual service implementation. We don't want to expose the actual implementation URI of our service for security reasons. We will use only the proxy URI for public use, so the proxy will be the first point of access. We can apply various security policies on the proxy, and thus it decouples the security stuff from the actual service implementation.
N.B: The proxy is nothing but a Mule application. You can download the proxy application from Cloudhub and import it as a Mule project. The project contains a single flow that makes an HTTP/HTTPS call to the actual implementation of the API, i.e. experience-api-mobile in our case.
API Manager - Update RAML
At this point, we have our actual service up and running and the proxy up and running. Now we would like to update the baseUri of the RAML pointing to the proxy deployed.
Now you are done. You can apply the security policies as necessary to the API. Make the portal public and expose for public use.
Here I have shown how easy it is to use API Manager to manage APIs. There are many other features of API Manager apart from managing APIs. One can also check the various statistics of API usage via API Manager.
Opinions expressed by DZone contributors are their own.