Abstract
With the increasing number of Web Services, providing accurate and efficient Web APIs to meet the growing demands of developers for Mashups has become a significant challenge. Most existing methods may have not explicitly considered the deep semantic relationships between Web APIs and Mashups, leading to poor recommendation accuracy. In addition to the accuracy of recommendation results, diversity is also considered a key factor in broadening user perspectives and enhancing user satisfaction. However, most current methods have failed to simultaneously explore the assistance of knowledge graphs in accuracy and diversity. To address this problem, this paper proposes a deep knowledge and diversity-awarded Web API recommendation approach (named APIRec). Firstly, We utilize the Mashup-API collaborative invocation pattern and service category attributes to construct a streamlined knowledge graph. Secondly, in this hybrid Mashup-API structure, high-order relations between entities are explicitly implemented in the knowledge graph using an end-to-end approach to uncover hidden relationships among entities. Subsequently, attention mechanisms are employed to model and measure the importance of neighbors. Finally, to enhance the diversity of recommendation results, Maximal Marginal Relevance (MMR) is utilized to measure the accuracy and diversity of the recommended results simultaneously. To verify the effectiveness of APIRec, we conduct extensive experiments on real-world datasets collected from ProgrammableWeb.com. The experimental results show that APIRec outperforms other state-of-the-art approaches by 2.62%, 4.20%, and 22.69% in terms of mean precision (MP), mean recall (MR), and mean inter-list diversity (MILD), respectively.
Introduction
In the modern web ecosystem, developers rarely build everything from scratch; they create "Mashups" by integrating multiple Web APIs, such as Google Maps, Twilio, or Stripe. However, with tens of thousands of APIs available, finding the right combination has become a "needle-in-a-haystack" problem.
Existing recommendation systems often suffer from two primary limitations. First, they rely on shallow relationships, using simple collaborative filtering that ignores deep semantic connections like shared categories or complex usage patterns. Second, they often create a filter bubble by optimizing solely for accuracy, which leads to recommending the same popular APIs repeatedly and prevents developers from discovering niche but highly effective tools.
The APIRec Framework
To overcome these challenges, the authors introduce APIRec, a framework designed to balance recommendation accuracy with result diversity through three main stages.
1. Knowledge Graph (KG) Construction
Instead of just looking at Mashup-to-API interactions, APIRec builds a streamlined graph that includes Mashups, APIs, and their functional categories. This creates a semantic map of how services relate to one another through shared attributes.
2. Attention-Based High-Order Propagation
This stage models "high-order" semantic relationships using a Graph Neural Network (GNN) approach. The model recursively propagates information across multiple "hops" (e.g., Mashup $\to$ API $\to$ Category $\to$ another API). An attention mechanism is employed to weigh these connections, ensuring the model focuses on the most relevant semantic paths.
3. Diversity-Aware Re-ranking (MMR)
To address the diversity problem, APIRec utilizes the Maximal Marginal Relevance (MMR) algorithm. During the final ranking stage, MMR selects APIs that are highly relevant to the user but also dissimilar to the APIs already selected for the recommendation list, effectively breaking the filter bubble.
Experimental Evaluation
The researchers evaluated APIRec using a real-world dataset from ProgrammableWeb.com, featuring 6,198 Mashups and 13,425 APIs.
Key Results
APIRec was tested against several state-of-the-art baselines, including KGAT and CKE, showing significant improvements across all metrics:
- Accuracy: Improved Mean Precision (MP) by 2.62% and Mean Recall (MR) by 4.20%.
- Diversity: Achieved a massive 22.69% improvement in Mean Inter-list Diversity (MILD).
- Statistical Significance: Improvements were confirmed via the Wilcoxon signed-rank test ($p < 0.05$).
Insights on Model Depth
Ablation studies revealed that performance peaks at 3 layers of graph propagation. Beyond this depth, the model begins to incorporate "noise" from distant, unrelated nodes, which can lead to overfitting and reduced accuracy.
Conclusion and Future Work
APIRec demonstrates that modeling high-order relations in a knowledge graph can significantly uncover hidden API candidates that traditional methods miss. While the framework currently relies on metadata from ProgrammableWeb, future work aims to incorporate Quality of Service (QoS) metrics—such as latency and reliability—to ensure recommended APIs are not only relevant but also performant. Additionally, the authors plan to optimize the computational overhead of the MMR re-ranking algorithm for larger-scale, real-time applications.
Summary updated