To determine the spectral class of a star, the most necessary piece of data is temperature.
The spectral class of a star is primarily based on its surface temperature, which affects the star's spectrum and the type of absorption lines visible in the light it emits. The spectral classification system (O, B, A, F, G, K, M) categorizes stars based on their temperature and the characteristics of their spectra. While other factors such as luminosity and absolute magnitude are important for understanding a star's properties, they do not directly determine its spectral class.