The code you posted will only work for old-style (pre 5.x) pets. You'll need to use the C_PetJournal functions for them now to access both old and new-style. Take a look at some of the newer Pet-centric AddOns (such as
Pet Theory) for some code examples.
I'd use
WoWPedia over WoWWiki, as it's much better maintained.