Microorganisms are one of the most promising biomarkers for cancer, and the relationship between microorganisms and lung cancer occurrence and development provides significant potential for pulmonary nodule (PN) diagnosis from a microbiological perspective. This study aimed to analyze the salivary microbiota features of patients with PN and assess the potential of the salivary microbiota as a non-invasive PN biomarker. We collected saliva smples from 153 patients with PN and 40 controls. Using 16 S rRNA gene sequencing, differences in alpha- and beta-diversity and community composition between the group with PN and controls were analyzed. Subsequently, specific microbial variables were selected using six models were trained on the selected salivary microbial features. The models were evaluated using metrics, such as the area under the receiver operating characteristic curve (AUC), to identify the best-performing model. Furthermore, the Bayesian optimization algorithm was used to optimize this best-performing model. Finally, the SHapley Additive exPlanations (SHAP) interpretability framework was used to interpret the output of the optimal model and identify potential PN biomarkers. Significant differences in alpha- and beta-diversity were observed between the group with PN and controls. Although the predominant genera were consistent between the groups, significant disparities were observed in their relative abundances. By leveraging the random forest algorithm, ten characteristic microbial variables were identified and incorporated into six models, which effectively facilitated PN diagnosis. The XGBoost model demonstrated the best performance. Further optimization of the XGBoost model resulted in a Bayesian Optimization-based XGBoost (BOXGB) model. Based on the BOXGB model, an online saliva microbiota-based PN prediction platform was developed. Lastly, SHAP analysis suggested Defluviitaleaceae_UCG-011, Aggregatibacter, Oribacterium, Bacillus, and Prevotalla are promising non-invasive PN biomarkers. This study proved salivary microbiota as a non-invasive PN biomarker, expanding the clinical diagnostic approaches for PN.