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!

  • Avatar of endx7 endx7 Aug 27, 2016 at 23:34 UTC - 0 likes

    @yammyblack: Go

    This looks like an error from an old version.

  • Avatar of yammyblack yammyblack Aug 27, 2016 at 19:07 UTC - 0 likes


    i would like to report the error on legion pre launch. august 27 2016.

    i hope you can figure it out. thanks


    Date: 2016-08-27 15:24:05 ID: 1 Error occured in: Global Count: 1 <</code>>
    Message: ...llector\Libs\LibPetJournal-2.0\LibPetJournal-2.0.lua line 56:
    table index is nil
    ...llector\Libs\LibPetJournal-2.0\LibPetJournal-2.0.lua:56: in main chunk
    MAJOR = "LibPetJournal-2.0"
    MINOR = 27
    lib = <table> {
    UnregisterCallback = <function> defined @Interface\AddOns\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:179
    callbacks = <table> {
    event_frame = <unnamed> {
    UnregisterAllCallbacks = <function> defined @Interface\AddOns\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:200
    RegisterCallback = <function> defined @Interface\AddOns\Ace3\CallbackHandler-1.0\CallbackHandler-1.0.lua:116
    oldminor = nil
    _G = <table> {
    ERR_OUT_OF_CHI = "Not enough chi"
    DH_HAVOC_CORE_ABILITY_2 = "Strong melee attack that consumes Fury. If it critical strikes, some Fury is refunded."
    MultiCastActionButton6Cooldown = MultiCastActionButton6Cooldown {
    MerchantItem9ItemButtonStock = MerchantItem9ItemButtonStock {
    GetTrainerServiceTypeFilter = <function> defined =[C]:-1
    UNIT_NAMES_COMBATLOG_TOOLTIP = "Color unit names."
    ARL_DatamineCopyFrame = ARL_DatamineCopyFrame {
    SetTrainerServiceTypeFilter = <function> defined =[C]:-1
    SPELL_FAILED_CUSTOM_ERROR_71 = "This partygoer wants to dance with you."
    RecruitAFriendFrame = RecruitAFriendFrame {
    CompactUnitFrameProfilesGeneralOptionsFrameHealthTextDropdownButtonNormalTexture = CompactUnitFrameProfilesGeneralOptionsFrameHealthTextDropdownButtonNormalTexture {
    TutorialFrameLeft19 = TutorialFrameLeft19 {
    MultiCastActionButton2Cooldown = MultiCastActionButton2Cooldown {
    ERR_TRADE_EQUIPPED_BAG = "You can't trade equipped bags."
    PVP_RANK_6_1 = "Corporal"
    BOOKTYPE_PROFESSION = "professions"
    AudioOptionsVoicePanelOutputDeviceDropDownButtonHighlightTexture = AudioOptionsVoicePanelOutputDeviceDropDownButtonHighlightTexture {
    VideoOptionsFrameCategoryFrameButton17ToggleHighlightTexture = VideoOptionsFrameCategoryFrameButton17ToggleHighlightTexture {
    MerchantItem2AltCurrencyFrameItem1Text = MerchantItem2AltCurrencyFrameItem1Text {
    OPTION_TOOLTIP_ACTION_BUTTON_USE_KEY_DOWN = "Action button keybinds will respond on key down, rather than on key up."
    BINDING_NAME_NAMEPLATES = "Show Enemy Name Plates"
    IsReferAFriendLinked = <function> defined =[C]:-1
    MAIL_LETTER_TOOLTIP = "Click to make a permanent
    copy of this letter."
    AudioOptionsVoicePanelMicrophoneVolumeThumb = AudioOptionsVoicePanelMicrophoneVolumeThumb {
    PaperDollTitlesPaneButton12BgTop = PaperDollTitlesPaneButton12BgTop {
    FCFDockOverflowButton_OnClick = <function> defined @Interface\FrameXML\FloatingChatFrame.lua:2337
    TutorialFrameRight19 = TutorialFrameRight19 {
    ChatFrame6EditBoxFocusMid = ChatFrame6EditBoxFocusMid {
    BN_UNABLE_TO_RESOLVE_NAME = "Unable to whisper '%s'. may be unavailable."
    CompactRaidFrameManagerDisplayFrameHiddenModeToggleTopRight = CompactRaidFrameManagerDisplayFrameHiddenModeToggleTopRight {
    LFGTeleport = <function> defined =[C]:-1
    SpellButton6Cooldown = SpellButton6Cooldown {
    SLASH_LibQTip1 = "/qtip"
    ToggleEncounterJournal = <function> defined @Interface\FrameXML\UIParent.lua:788
    Graphics_QualityText = Graphics_QualityText {
    TalentMicroButtonAlertShadowTopLeft = TalentMicroButtonAlertShadowTopLeft {
    ROGUE_COMBAT_CORE_ABILITY_4 = "Melee ability with an increased range that consumes Combo Points."
    JoinSkirmish = <function> defined =[C]:-1
    Advanced_GraphicsAPIDropDownButtonHighlightTexture = Advanced_GraphicsAPIDropDownButtonHighlightTexture {
    CompactUnitFrameProfilesSaveButton = CompactUnitFrameProfilesSaveButton {
    MainMenuXPBarDiv8 = MainMenuXPBarDiv8 {
    LFGListSearchPanelScrollFrameButton10BottomRight = LFGListSearchPanelScrollFrameButton10BottomRight {
    DMG_LCD = "DMG"
    VideoOptionsPanel_Cancel = <function> defined @Interface\SharedXML\VideoOptionsPanels.lua:314
    ChannelMemberButton10SpeakerFrameOn = ChannelMemberButton10SpeakerFrameOn {
    BetterFont, v7.0.1
    MoncaiCompare, v7.0.0
    Swatter, v7.0.5661 (TasmanianThylacine)
    Ace3, v
    AckisRecipeList, v7.0.3.6
    AckisRecipeListQuickScan, v6.2.0.1
    AllPlayed, vv70000-2
    Atlas, v1.33.02
    AtlasArena, v1.06.01
    AtlasBattlegrounds, v1.33.00
    AtlasBurningCrusade, v1.33.00
    AtlasCataclysm, v1.33.00
    AtlasClassicWoW, v1.33.01
    AtlasDungeonLocs, v1.33.01
    AtlasLegion, v1.34.00
    AtlasMistsofPandaria, v1.33.00
    AtlasOutdoorRaids, v1.33.01
    AtlasScenarios, v1.33.00
    AtlasTransportation, v1.33.02
    AtlasWarlordsofDraenor, v1.33.01
    AtlasWorldEvents, v3.15
    AtlasWrathoftheLichKing, v1.33.01
    AucAdvanced, v7.0.5661 (TasmanianThylacine)
    AucFilterBasic, v7.0.5661 (TasmanianThylacine)
    AucFilterOutlier, v7.0.5661.5459(/embedded)
    AucMatchUndercut, v7.0.5661.5585(/embedded)
    AucStatHistogram, v7.0.5661 (TasmanianThylacine)
    AucStatiLevel, v7.0.5661 (TasmanianThylacine)
    AucStatPurchased, v7.0.5661 (TasmanianThylacine)
    AucStatSales, v7.0.5661.5598(/embedded)
    AucStatSimple, v7.0.5661 (TasmanianThylacine)
    AucStatStdDev, v7.0.5661 (TasmanianThylacine)
    AucStatWOWEcon, v7.0.5661.5613(/embedded)
    AucUtilAHWindowControl, v7.0.5661.5575(/embedded)
    AucUtilAppraiser, v7.0.5661.5653(/embedded)
    AucUtilAskPrice, v7.0.5661.5599(/embedded)
    AucUtilAutoMagic, v7.0.5661.5587(/embedded)
    AucUtilCompactUI, v7.0.5661.5629(/embedded)
    AucUtilEasyBuyout, v7.0.5661.5576(/embedded)
    AucUtilFixAH, v7.0.5661 (TasmanianThylacine)
    AucUtilItemSuggest, v7.0.5661.5651(/embedded)
    AucUtilPriceLevel, v7.0.5661.5633(/embedded)
    AucUtilScanButton, v7.0.5661.5631(/embedded)
    AucUtilScanFinish, v7.0.5661.5588(/embedded)
    AucUtilScanProgress, v7.0.5661.4979(/embedded)
    AucUtilScanStart, v7.0.5661.5347(/embedded)
    AucUtilSearchUI, v7.0.5661.5657(/embedded)
    AucUtilSimpleAuction, v7.0.5661.5654(/embedded)
    AucUtilVendMarkup, v7.0.5661.4828(/embedded)
    AutoProfitX2, v7.001
    Babylonian, v5.1.DEV.332(/embedded)
    BankItems, v6.1.0.0
    BankItemsMailWatch, v1.0.60200
    BattlePetMap, v1.0.5
    BattlePetsCollector, v6.0.3.10
    Carbonite, v6.2.0
    Configator, v5.1.DEV.406(/embedded)
    DebugLib, v5.1.DEV.337(/embedded)
    LibExtraTip, v5.12.DEV.407(/embedded)
    Stubby, v7.0.5661 (TasmanianThylacine)
    TipHelper, v5.12.DEV.405(/embedded)
    BlizRuntimeLib_enUS v7.0.3.70000 <none>


    Last edited Aug 27, 2016 by yammyblack
  • 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


Table of contents

  1. 1 Links
  2. 2 Example


Date created
Sep 03, 2012
Last update
Jul 19, 2016
Development stage
MIT License
Curse link
Reverse relationships
Recent files
  • A: r125 for 7.0.3 Jul 19, 2016
  • R: 2.0.32 for 6.2.4 Jul 18, 2016
  • A: r124 for 6.2.4 Jul 18, 2016
  • A: r123 for 6.2.4 Jul 18, 2016
  • A: r122 for 6.2.4 Jul 15, 2016