BACKGROUNDDiabetic retinopathy (DR) is a common complication of diabetes, with Endoplasmic reticulum stress (ERS) playing a key role in cellular adaptation, injury, or apoptosis, impacting disease pathology. This study aimed to identify early diagnostic markers for personalized DR treatment.METHODSDR and healthy control (HC) samples were collected from the Gene Expression Omnibus (GEO) database. Differentially expressed ERS-related genes (DE-ERSRGs) were identified, and machine learning algorithms were used to pinpoint DR-specific feature DE-ERSRGs (FDE-ERSRGs). Diagnostic accuracy was assessed using ROC curve analysis. Further analyses included differential expression, co-expression, GO functional, KEGG pathway enrichment, and immune cell infiltration profiling in DR.RESULTSA total of 55 DE-ERSRGs were initially identified, and after further analysis, two key FDE-ERSRGs, SELENOS and heat shock protein family A member 5 (HSPA5), were highlighted due to their robust differential expression patterns between DR and healthy controls. Both genes exhibited high diagnostic potential, with AUC values of 0.792 and 0.799, respectively, indicating their promise as biomarkers for DR. Additionally, we examined the differential and co-expression patterns of DE-ERSRGs between high- and low-expression groups. We investigated the molecular functions and biological pathways associated with DR, analyzed immune cell infiltration differences between DR and HC groups, and assessed their correlation with FDE-ERSRGs.CONCLUSIONSOur findings provide new insights into the molecular mechanisms and metabolic pathways involved in DR, potentially paving the way for the identification of novel diagnostic and immunotherapeutic biomarkers.