Requires: LibStub, CallbackHandler-1.0

With 5.0 a new C_PetJournal API was introduced, and unfortunately the old GetCompanionInfo API no longer works properly (it does not, for example, know anything about non-combat pets obtained before the account-wide merge, and you also can no longer summon non-combat pets using it).

This library provides the list of player owned pet ids and all species ids, which can be used with C_PetJournal.GetPetInfoByPetID() and C_PetJournal.GetPetInfoBySpeciesID().

It primarily deals with two problems with scanning the pet journal:

  • Filters: The Pet Journal filters are cleared and then restored, as they affect the return values given from C_PetJournal.GetPetInfoByIndex()
  • Updating in response to event: Manipulating the Pet Journal filters causes PET_JOURNAL_LIST_UPDATE to fire, which is also the only event that always fires when you lose or gain a pet. Filter manipulation is detected and we never try to rescan pets in response. When this is not the case, a CallbackHandler event is fired which can be used to safely detect changes to the pet list.

Getting Started
API Documentation
WoWAce Thread


local LibPetJournal = LibStub("LibPetJournal-2.0")
local function ScanPets()
    for _,petid in LibPetJournal:IteratePetIDs() do 
        local speciesID, customName, level, xp, maxXp, displayID, isFavorite, 
               name, icon, petType, creatureID, sourceText, description, isWild,
               canBattle, tradable, unique = C_PetJournal.GetPetInfoByPetID(petid)
        if name == "Feline Familiar" then
            print("Player has a cat in a hat.")

If you wanted to automatically scan for little cats in hats when the pet list changes, you could register a callback, such as:

LibPetJournal.RegisterCallback(addon, "PetListUpdated", ScanPets)

Obviously you would normally use the speciesID or creatureID return values from C_PetJournal.GetPetInfoByPetID() to find a particular pet, but this is just a silly example.

You must login to post a comment. Don't have an account? Register to get one!

  • 1 comment
  • Avatar of Jelach Jelach Feb 27, 2014 at 03:30 UTC - 0 likes

    My OS is Windows 7 Home Premium (all patched, with latest drivers). I am running the latest version of WoW (5.4.7 [17930] Release x64). All my addons are installed via the Curse Client and are up-to-date.

    You can partition the addons I use into two sets:
    (1) Addons relating to pets or the pet journal
    (2) Everything else.

    WoW+Set(2) addons work fine. No problems, no loss of functionality, etc.

    WoW+Set(1) addons cause WoW to lose functionality within the UI.

    Set(1) consists of:
    Better Battle Pet Tooltip
    PetBattle Teams
    PetJournal Enhanced
    Pokemon Trainer: The Pet Battle Mod

    If I activate any one of the above addons, the problem occurs.

    The game acts like something is broken within the UI and 'actions' are getting lost. Here are some examples of what I see:
    (a) I bring up the System Menu, via hotkey. I select the Logout button or the Exit button. The System Menu disappers, but nothing happens: My character remains in-game. If I select other buttons from the System Menu (like Keybind or Interface), their appropriate menu pops up.
    (b) I target a merchant NPC. The NPC gives me the normal voice response, but its merchant window does not pop up. Nothing happens. My character remains active.
    (c) I have the Mining skill. I find an ore node. I select it to start mining. I get the 'mining activity' graphic display but nothing else - no progress bar and no change in the ore node. If I don't move my character, I would 'mine' forever.
    (d) I have a pet (warlock or hunter) active. When I move, my pet does not follow me - it remains it the location it was in when I entered the game.

    I can see all the in-game NPCs, mobs, and other players. I can click on them (see [b] above) but otherwise not interact with them.

    I have run the WoW repair activity. I have deleted and re-downloaded the addons. I have deleted WoW's cache directory. It made no difference. Activating any of the Set(1) addons causes the problem. Deactivating all of the Set(1) addons 'clears' the problem. If the Set(1) addons are downloaded/installed but not activated, there are no problems. I can:
    (a) Activate one Set(1) addon (any one).
    (b) Get into the game.
    (c) Verify the problem (by trying to logout and not being able to).
    (d) Kill the game from the desktop (since the Exit command does not work).
    (e) Deactivate the addon from (a)
    (f) Get into the game.
    (g) Verify that the problem does not happen and everything is fine.

    There are no error popups, LUA warnings, etc. when I am having the problem.

    I have determined the following:
    (a) Select one of the Set(1) addons.
    (b) Go into it's *.toc file and comment out the reference to LibPetJournal-2.0.
    (c) Get into the game.
    (d) Verify that the problem does not happen.

    Ie., Having this single library present or absent gives me the problem.  And this happens for all the Set(1) addons.  Furthermore, only the Set(1) addons use this library - all my other addons (the Set(2) group) do not use it.

    Now, I do get one or more LUA errors about the missing library from the Set(1) addons, so the Set(1) addons do not function or function only partly.  But they no longer mess up my UI as described earlier.

    I would be happy to run tests or a debug version of LibPetJournal to help determine what is going on.  The addon 'Better Battle Pet Tooltip' in particular is probably a good test-bed, as it is very small and uses only LibPetJournal and its two dependent libraries.

    You can contact me via

  • 1 comment

Table of contents

  1. 1 Links
  2. 2 Example


Date created
Sep 03, 2012
Last update
May 13, 2016
Development stage
MIT License
Curse link
Reverse relationships
Recent files
  • A: r114 for 6.2.4 May 13, 2016
  • A: r113 for 6.2.4 May 13, 2016
  • R: 2.0.28 for 6.2.2 Oct 24, 2015
  • A: r106 for 6.2.2 Oct 24, 2015
  • A: r105 for 6.2.2 Oct 17, 2015