WebAPIRec: Recommending Web APIs to Software Projects via Personalized Ranking

Ferdian Thung, Richard Jayadi Oentaryo, David Lo, Yuan Tian

Abstract

The proliferation of Web APIs has created a significant discovery challenge for software developers. Traditional keyword-based search engines often fail to capture the nuanced requirements of complex projects. This paper presents WebAPIRec, an automated recommender system that utilizes a personalized ranking model to suggest relevant APIs based on project descriptions. By framing the recommendation task as a "learning to rank" problem and incorporating both collaborative and content-based features, WebAPIRec achieves a Hit@5 rate of 84%, significantly outperforming existing search and recommendation baselines.

Introduction

Modern software development is increasingly modular, relying on third-party Web APIs to provide specialized functionality. However, as the ecosystem grows to include tens of thousands of APIs, identifying the most suitable tools becomes difficult. Existing platforms like ProgrammableWeb often rely on rigid boolean search logic, which can result in zero matches for detailed queries. Conversely, popularity-based systems ignore the specific context of a project. WebAPIRec addresses these issues by providing a ranked list of APIs tailored to a project's textual requirements.

Methodology

The core of WebAPIRec is a Personalized Ranking Model designed to optimize the relative ordering of APIs rather than performing binary classification. This approach acknowledges that "unused" APIs in training data are often simply "unobserved" by developers rather than irrelevant.

WebAPIRec System Architecture

The system processes project descriptions using a Natural Language Processing (NLP) pipeline that includes noun extraction via the Stanford POS tagger, tokenization, stop-word removal, and Porter stemming. Nouns are prioritized as they typically represent the functional requirements of a project. The model is optimized using a squared hinge loss function and a truncated Newton method, ensuring efficient training and high sensitivity to ranking errors.

Feature Engineering

WebAPIRec utilizes twelve distinct features categorized into project-based and API-based groups. Project-based features ($x_1$ to $x_{10}$) leverage collaborative filtering by identifying the top-$k$ most similar past projects using cosine similarity of descriptions. Empirical testing identified $k=15$ as the optimal neighborhood size. API-based features ($x_{11}$ and $x_{12}$) measure the direct textual similarity between project profiles and API documentation.

Ranking Model Feature Definitions

Experimental Evaluation

The system was evaluated using a dataset scraped from ProgrammableWeb, consisting of 9,883 APIs and 4,315 projects. To ensure the integrity of the evaluation, API names were automatically removed from project descriptions to prevent the model from "cheating" via simple name matching.

Results

WebAPIRec demonstrated superior performance across all metrics. It achieved a Hit@5 of 0.840 and a Mean Reciprocal Rank (MRR) of 0.750. Compared to the best-performing baseline, PopRec, WebAPIRec showed a 42.1% improvement in Hit@5. Furthermore, the system is computationally efficient, generating recommendations in approximately 0.0013 seconds after a three-minute training phase.

Conclusion

WebAPIRec provides a robust solution to the API discovery problem by combining collaborative filtering with content-based ranking. By focusing on the relative ranking of APIs, the system effectively handles the ambiguity of unobserved data. Future work will explore enriching API profiles with external data from sources like GitHub and StackOverflow to mitigate data sparsity and improve recommendation accuracy in more diverse contexts.

Summary updated

BibTeX
@article{thung2017webapirec,
  author = {Ferdian Thung and Richard Jayadi Oentaryo and David Lo and Yuan Tian},
  title = {{WebAPIRec: Recommending Web APIs to Software Projects via Personalized Ranking}},
  journal = {IEEE Trans. Emerg. Top. Comput. Intell.},
  year = {2017},
  doi = {10.1109/tetci.2017.2699222},
}
Figure