Provided are a recombinant group 2 allergen protein from Dermatophagoides pteronyssinus, and an encoding gene and preparation method thereof. The encoding gene is obtained by preforming codon optimization on a wild-type encoding gene of a group 2 allergen protein from Dermatophagoides pteronyssinus and is beneficial to expression in Pichia pastoris. Further, an acting element increasing target protein expression is added to the expression system.