The article deals with the internal ballistic of an air gun that utilizes the energy of compressed air to propel the projectile out of the barrel. In this study, a thermodynamic mathematical model describing the internal ballistic phenomena inside the working chambers of an airgun is developed. The core of this work is to derive a governing equation modeling the variation of gas temperature in a control volume including one or several incoming and outgoing mass airflow rates. A novel universal algorithm that allows to solve internal ballistics of all types of airguns is also developed and applied for the case of spring-piston airgun. To verify the mathematical model, the projectile muzzle velocity is measured using a Dopler radar system and compared to the theoretical result. The comparison reveals that the measured and calculated results of the projectile muzzle velocity are well agreed with the deviation less than 4%. Thus, the developed internal ballistic model of airguns and its solving algorithm can be used as a powerful tool to predict and improve the existing airguns performance or to design novel airgun systems.