Objective We aimed to evaluate whether the Chinese medicine compound Xinfeng Capsule (XFC) is associated with the incidence of endpoint events ( readmission, extra-articular lesions, and surgical treatment ) in patients with ankylosing spondylitis ( AS ). Methods Clinical data were retrospectively collected from 1 621 AS patients discharged from the Department of Rheumatology and Immunology of the First Affiliated Hospital of Anhui University of Chinese Medicine between June 2012 and June 2022. XFC users and non-XFC users were defined as the XFC group and non-XFC group, respectively. Propensity score matching was used to match baseline data. A random walk model was used to evaluate the effects of western drugs combined with XFC treatment on the improvement of immunoinflammatory indexes. Association rules were used to analyze the association between XFC and improvement of clinical immunoinflammatory indexes in AS. Multivariate COX analysis including XFC, gender, age, hypertension, diabetes, hyperlipidemia, osteoporosis, hepatic insufficiency, and chronic hepatitis B was performed to determine the risk of readmission, extra-articular lesions, and surgical treatment. Results A total of 1 455 patients with AS were included. After propensity score matching, baseline data for XFC users were consistent with those for non-XFC users, with 203 cases in each group. Retrospective data mining showed that XFC significantly reduced clinical immunoinflammatory markers in patients with AS, and random walk result suggested that XFC treatment was associated with long-term improvement in immunoinflammatory markers. The result of association rule analysis showed that XFC was strongly associated with the improvement of immune inflammatory markers. The prognosis of the overall endpoint events was better in XFC users compared to non-XFC users (χ 2 = 11. 678, HR = 0. 65, 95%CI = 0. 500-0. 810, P < 0. 01). The risk of endpoint events was significantly lower in XFC users with high exposure intensity (HR = 0. 504, 95%CI = 0. 357-0. 711) and moderate exposure intensity (HR = 0. 576, 95%CI = 0. 380-0. 873) than in non-XFC users. Conclusion The herbal compound XFC is associated with a lower incidence of endpoint events (readmission, extra-articular lesions, and surgical treatment) in AS; long-term exposure to XFC may significantly reduce the occurrence of endpoint events. [ABSTRACT FROM AUTHOR]