When retrieving a Pet Spell using GetSpellBookItemInfo, the resulting number is a spellID with flags attached. If you use "bitwise.and" with the number 16777215, you will get a spellID that works with type "spell". The greatest 8 bits, at least, are flags.
From the patterns I have seen and with the the least significant bit is bit 1, Bit 25 (2^24) is set for all pet spells, Bit 31 (2^30) is the state of Autocast (1 = Autocast on, 0 = Autocast off), and Bit 32 (2^31) is if the spell is castable or passive (1 = castable, 0 = passive).
18.104.22.168 19:48, October 22, 2019 (UTC)