API protocols are important for modern software development. They can be used in program testing, documentation, understanding and validation. Mining API protocols based on probabilistic models is proved to be an effective method to achieve protocols automatically. In this paper, we discuss the unbalanced probability problem caused by loops and recursive functions in application programs and a method based on the suffix tree is proposed to address it. In order to investigate the feasibility and effectiveness of our approach, we implemented it in our previous prototype tool ISpecMiner and performed a comparison test based on several real-world applications. Experimental results show that our approach can achieve protocols with more balanced probabilities than existing approaches, which provides a strong assurance for achieving valid and precise API protocols.