Avenue Code Snippets

API Autodiscovery in Anypoint Platform 2

Written by Anupam Gogoi | 6/6/18 8:00 PM

With the release of Anypoint Platform 2, there are some exciting changes in the API Autodiscovery feature. Here in this short article, I am going to describe how to make use of it in your applications.

API Road Map

This is the basic roadmap for API development in Anypoint Platform. For the purposes of this article, we will not go into all the steps, but will just focus on the most relevant - the API Manager.

API Manager

This is the most important tool for managing (governing) the APIs. An API, to be managed it must have an instance created, and this instance must be associated with an actual implementation of the API. Also, to apply necessary security policies the API instance is a must need. 

Note: Previously in Anypoint Platform 1, there was the concept of creating a Proxy for the API to manage it. But, now with the new version of Anypoint Platform, it can be done through the API instance. This means that you do not need to explicitly create a Proxy only to apply some policy. Now you can directly apply the policies on the API instance. 

So, here is a screenshot to create an API instance,

The most important part is to mark the checkbox. Once you save it, the API instance is created as shown below:

 

 

This is the most important part of API Autodiscovery. You can create more than one instance of the same API. Once the API instance is created you can have the instance ID as shown above.

At this stage, your API instance is not managed. (Status is shown as Unregistered). It means that till now it has not yet been associated with an actual implementation. 

 

Anypoint Studio

After API specification is ready you can import it directly from the Design Center in the Anypoint Studio. Now, configure an API Autodiscovery global element and provide it with the API Instance ID,

Runtime Manager

Once the implementation is complete publish it to Runtime Manager. Before deploying just make sure that you configure the following properties. This is the most important part otherwise your API will not be managed. 

Note: The client_id & client_secret are the credentials of your master organization or Business Group for whom you are developing the APIs.

Once the application is up and running you can see the status of the API as active in the API manager.

 

Behind The Scenes

At this stage, your API is completely managed by the platform. Any request that comes to the application endpoint is first intercepted by the API manager to collect statistics, etc. If you apply security policies (API Manager) the request will be intersected at the API manager to apply the security policies. 

Conclusion

In this tutorial, I have shown how to use the API Autodiscovery in Anypoint Platform 2. As you can see, the release of the new version of the platform has made things far easier to understand and use!