Code2API: A Tool for Generating Reusable APIs from Stack Overflow Code Snippets

Nowadays, developers often turn to Stack Overflow for solutions to daily problems, however, these code snippets are partial code that cannot be tested and verified properly. One way to test these code snippets is to transform them into APIs (Application Program Interface) that developers can directly invoked and executed. However, it is often costly and error-prone for developers to manually perform this transformation (referred to as AIPzation task) due to different actions to be taken (e.g., summarizing proper method names, inferring input parameters list and return statements). To help developers quickly reuse code snippets in Stack Overflow, in this paper, we propose Code2API, a Google Chrome extension that uses Large Language Models (LLMs) to automatically perform APIzation of code snippets on Stack Overflow. Code2API guides LLMs through well-designed prompts to generate reusable APIs, using Chain-of-Thought reasoning and few-shot in-context learning to help LLMs understand and solve the APIzation task in a developer-like manner. The evaluation results show that Code2API significantly outperforms the rule-based approach by a large margin. The full paper of this tool has been published in FSE'24 as a research paper [11].

Authors

Institutions

Publication Details

Published
2025-06-06
DOI
https://doi.org/10.1145/3713081.3731741
Primary Topic
Software Engineering Research
Type
article
Field-Weighted Citation Impact
0.00
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

Code2API: A Tool for Generating Reusable APIs from Stack Overflow Code Snippets

Zhipeng Gao, Lingfeng Bao, Jingyuan Chen, Xing Hu et al.
Software Engineering Research
article

Code2API: A Tool for Generating Reusable APIs from Stack Overflow Code Snippets

Zhipeng Gao, Lingfeng Bao, Jingyuan Chen, Xing Hu, Jianling Sun, Yubo Mai
article en

Abstract

Nowadays, developers often turn to Stack Overflow for solutions to daily problems, however, these code snippets are partial code that cannot be tested and verified properly. One way to test these code snippets is to transform them into APIs (Application Program Interface) that developers can directly invoked and executed. However, it is often costly and error-prone for developers to manually perform this transformation (referred to as AIPzation task) due to different actions to be taken (e.g., summarizing proper method names, inferring input parameters list and return statements). To help developers quickly reuse code snippets in Stack Overflow, in this paper, we propose Code2API, a Google Chrome extension that uses Large Language Models (LLMs) to automatically perform APIzation of code snippets on Stack Overflow. Code2API guides LLMs through well-designed prompts to generate reusable APIs, using Chain-of-Thought reasoning and few-shot in-context learning to help LLMs understand and solve the APIzation task in a developer-like manner. The evaluation results show that Code2API significantly outperforms the rule-based approach by a large margin. The full paper of this tool has been published in FSE'24 as a research paper [11].

Shanghai University (CN), Zhejiang University (CN)
Openalex Percentile: Top 82%
Software Engineering Research
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.

Code2API: A Tool for Generating Reusable APIs from Stack Overflow Code Snippets — Zhipeng Gao, Lingfeng Bao, et al. · (2025) | TGRS Research Map | TGRS