API recommendation differs from conventional recommendation systems in that it integrates the characteristics of development requirements, mashup, and API, where there are two primary challenges, i.e., how to effectively mine the personalized development requirements of developers and the sparseness of interaction data. This research proposes a novel model framework, called Bayesian Probabilistic Matrix Factorization Model with Text Similarity and Adversarial Training (SAMF), to address these two issues. Utilizing natural language processing technology to extract the full-text semantics of requirements documents, mashup descriptions, and API descriptions, fully mining personalized development requirements, and contextual information of mashups and APIs, and calculating text similarity, is our fundamental idea. Simultaneously, the collaborative filtering method is used to mine user needs, mashup, and API information from historical data, and the obtained text similarity is added to the training as auxiliary information. Furthermore, adversarial training is further incorporated to supplement data in order to minimize data sparsity and enhance model robustness and generalization. To assess the performance of SAMF, we run thorough experiments that illustrate the efficacy of each module of the model and explain the influence of hyperparameter settings. Specifically, compared to the baseline, the experimental findings demonstrate that SAMF can basically achieve better performance.