Anaplasma phagocytophilum (A. phagocytophilum) is an emerging zoonotic pathogen causing human granulocytic anaplasmosis, linked to small mammal reservoirs that harbor various zoonotic pathogens, underscoring their importance in public health and ecology. This study seeks to determine the prevalence of A. phagocytophilum in small mammals using PCR, then sequence and genotype positive samples, and assess infection risk factors. Small mammals were seasonally captured and a nested polymerase chain reaction (nested-PCR) was conducted targeting the 16S rRNA gene on spleen samples to detect A. phagocytophilum infection from three counties in western Yunnan province, China. Positive samples were sequenced and genotyped, revealing genetic diversity and regional clustering of the pathogen. A total of 1,605 small mammals belonging to 30 species, 18 genera, 6 families, 3 orders were captured seasonally and screened in this region, yielding a 0.93% infection rate with A. phagocytophilum (15/1605). Significant variations in infection rates were observed across different species, counties, and habitats. The 16Sr RNA genes of A. phagocytophilum were categorized into two distinct clades, indicating notable genetic diversity. The identification of genetic variants in spleen samples underscores the potential public health risk and the critical importance of the One Health approach in disease surveillance. Our findings emphasize the necessity for continuous monitoring and highlight the value of nested-PCR testing on spleen samples for accurate prevalence assessment.