Putting APIs in the Right Order with Gated Graph Neural Networks

Published: 01 Jan 2024, Last Modified: 14 May 2025APSEC 2024EveryoneRevisionsBibTeXCC BY-SA 4.0
Abstract: API plays an important role in modern software development. Automatic API recommendation has been studied for years to facilitate developers' learning process of APIs. Previous approaches mainly use statistical models and collab-orative filtering (CF) techniques to mine API usage patterns for recommendation. Despite the encouraging results, they still struggle to obtain the accurate embeddings of the client methods and called APIs. Prior studies generally formulate the process of API call interactions as undirected graph structure, neglecting the order in which the API invocations appear, thus fail to seize the rich relationship and complex transitions of API calls. To transcend the limitations, we propose a novel method, namely PARO, to predict the next API invocations using gated graph neural networks (GGNNs). In our proposed method, the API call sequences are modeled as directed graphs, thus the GNN models prone to capture features such as the partial order and complex transitions between API invocations. Besides, we also learn the text attribute representations of API invocations and client methods through word embedding, which further corroborates the semantic and lexical similarities between them. We conduct experimental evaluations on a large number of Java projects extracted from Github and Maven Central. Results show that our approach outperforms the state-of-the-art by a large margin, in terms of Hit@N and MRR@N.
Loading