WSO2 APIM — AI based Recommendations for the Developer Portal
Introduction 📖
WSO2 API Manager stands out as a comprehensive and robust platform designed to streamline the entire lifecycle of APIs. It offers a range of powerful features and tools that empower organisations to create, manage, secure, and analyse APIs effectively.
WSO2 API Manager provides a centralised environment known as the Developer Portal, which serves as a marketplace for APIs. This portal facilitates collaboration between API publishers and application developers, ensuring a smooth and efficient API consumption process. API publishers can leverage the Publisher component of WSO2 API Manager to publish their APIs, while application developers can discover, explore, and subscribe to APIs that align with their project requirements through the Developer Portal.
WSO2 API Manager has the capability to provide API recommendations for the Developer Portal users based on Artificial Intelligence. Today we will explore more about this feature and configure it to get API recommendations.
Configurations ⚙️
Let’s use the latest update of API Manager 4.1.0 version (Update level 84 at the time of writing) for this.
- As the first step we need to set up the recommendation engine in our local machine which is the server that will be used to process the API recommendations. The server can be downloaded from link [1]. Follow the README section for the instructions on setting up this locally.
💡Make sure to use compatible software and library versions to avoid any errors while starting the server. To change the library versions, you may modify the <Recommendation_Server_Home>/requirements.txt file.
📝 Note: Python 3.8, MongoDB 6.0.6, Flask 2.3.2 and Werkzeug 2.3.6 were used in this demonstration.
- Default configurations of the recommendation server can be changed by modifying the <Recommendation_Server_Home>/repository/conf/config.yaml file as required.
- Add the following configurations in the <APIM_HOME>/repository/conf/deployment.toml file and start the API Manager server.
[apim.devportal.recommendations]
recommendations_api = "http://localhost:8082"
username = "admin"
password = "admin
- By default, recommendations are displayed only if the no. of apis in the Developer Portal exceeds 20 (This number can be changed from the <Recommendation_Server_Home>/repository/conf/config.yaml). Therefore lets create and publish 20 APIs from the Publisher Portal. For this example we will create APIs from below categories.
✍️ Countries, Currencies, Food, Pets and Vehicles
- Add appropriate tags to each API according to the API category.
🔖 Eg: country, currency, food, pet, vehicle
- Login to the Developer Portal and play around with the displayed APIs so the events to generate recommendations will be sent to the recommendation server. You could click on APIs, search for APIs, click on API tags, create applications with descriptions and subscribe to APIs to push events.
- Once the recommendations are generated by the recommendation server, those will be sent to the API Manager and displayed in the Developer Portal.
How It Works ? 🤔
The recommendation engine collects information about APIs and users from the API Manager and creates keyword dictionaries for each API and user. By calculating the similarities between the user’s dictionary and each API dictionary, the most relevant APIs are identified.
🔎 Let’s take a closer look at how this process works. First, the API Manager publishes specific details about an API to the recommendation server. These details include the API name, description, tags, context, and resources. This information helps create an API dictionary that captures the essence of the API.
Similarly, the recommendation server receives information about the user from the API Manager. This includes the APIs the user has clicked on, the tags they have interacted with, as well as details about the user’s application, such as the application name and description. Using this information, a user dictionary is created, reflecting their preferences and interests.
🛠️ To construct the keyword dictionaries, relevant keywords are extracted from the API and user details. These keywords are then assigned with weights based on their level of importance. This weighting ensures that more significant keywords have a stronger influence on the recommendation results.
Once the keyword dictionaries for both the APIs and users are prepared, the recommendation server calculates the similarities between each API dictionary and the user dictionary. This similarity calculation enables the system to identify the APIs that closely match the user’s preferences and needs.
🤖 By leveraging these keyword-based dictionaries and similarity calculations, WSO2 API Manager’s recommendation system offers personalised and relevant API suggestions to users. This intelligent approach simplifies the process of discovering APIs, helping developers to find the most suitable options for their projects with greater ease and efficiency.
Visit the official WSO2 documentation [2] about the AI based recommendations for the Developer Portal to get more information.
References
[1] https://github.com/wso2/product-apim/tree/master/modules/recommendation-engine
[2] https://apim.docs.wso2.com/en/4.1.0/consume/discover-apis/api-recommendations/