Both obesity and obstructive sleep apnea (OSA) can lead to metabolic dysregulation and systemic inflammation. Similar to obesity, increasing evidence has revealed that immune infiltration in the visceral adipose tissue (VAT) is associated with obstructive sleep apnea-related morbidity. However, the pathological changes and potential molecular mechanisms in visceral adipose tissue of obstructive sleep apnea patients need to be further studied. Herein, by bioinformatics analysis and clinical validation methods, including the immune-related differentially expressed genes (IRDEGs) analysis, protein-protein interaction network (PPI), functional enrichment analysis, a devolution algorithm (CIBERSORT), spearman’s correlation analysis, polymerase chain reaction (PCR), Enzyme-linked immunosorbent assay (ELISA) and immunohistochemistry (IHC), we identified and validated 10 hub IRDEGs, the relative mRNA expression of four hub genes (CRP, CD40LG, CCL20, and GZMB), and the protein expression level of two hub genes (CD40LG and GZMB) were consistent with the bioinformatics analysis results. Immune infiltration results further revealed that obstructive sleep apnea patients contained a higher proportion of pro-inflammatory M1 macrophages and a lower proportion of M2 macrophages. Spearman’s correlation analysis showed that CD40LG was positively correlated with M1 macrophages and GZMB was negatively correlated with M2 macrophages. CD40LG and GZMB might play a vital role in the visceral adipose tissue homeostasis of obstructive sleep apnea patients. Their interaction with macrophages and involved pathways not only provides new insights for understanding molecular mechanisms but also be of great significance in discovering novel small molecules or other promising candidates as immunotherapies of OSA-associated metabolic complications.