Skip to content

Hearthstone card data ​

Ruleset and calculator scripts get Hearthstone cards as plain objects straight from the card catalog. This page lists every field on those objects and in the catalog globals, with a real example and a few recipes.

Where the cards show up:

  • Card rules receive one card as their first argument.
  • Deck and deck set rules receive cardsById, an object keyed by card ref that holds every card in the deck (it can hold more).
  • Calculators receive cardsById as their second argument.

See the ruleset script API and the calculator script API for the full function signatures.

Card keys and deck refs ​

A Hearthstone card in the catalog is a card identity: one card with every printing of it listed under printings. Fireball in the Core set and the original Legacy Fireball are two printings of one identity. Two kinds of id matter:

  • The identity id, card.id: hs- plus a hash, like hs-64efa621e6de7e750001.
  • A printing id: Blizzard's card id, like CORE_CS2_029. Each printing's metadata carries its dbfId (the number a deck code stores) and its rarity.

cardsById is keyed by the deck's refs, and each one points to its identity, so two printings of the same card in one deck resolve to the same object:

  • Count copies of "the same card" by card.id, not by ref.
  • To read the printing a ref points to, find it in the list: card.printings.find((p) => p.id === ref).
  • ctx.globals.printings[ref] gives the identity id for a printing id, and ctx.globals.dbfIdToPrintingId maps a deck code's dbfId to its printing, when globals are available.

A card rule gets the identity card itself, so card.id is always the identity id.

The game fields describe the card's default printing (game.defaultPrintingId, the Standard-listed one first). That matters for per-printing fields such as dbfId, cardId, setId and rarity.

Guard against a missing card before reading from it: cardsById[ref] can be undefined when the catalog doesn't know a ref.

Card fields ​

Every card, in every game, has these top-level fields:

PropertyTypeDescription
idstringCatalog id of the card identity ("01DE012" in LoR, "pikachu-ex--1f29b66b68bc" in Pokémon).
slug?stringThe card's public URL segment (#2189, ADL §64): a frozen English slug, identical in every locale. Equals id for a game whose readable slugs are off (readableCardSlugsEnabled in @turny/game-adapters) or a card that has no readable slug yet. Pokémon keeps its <name>--<hash12> id as its slug; LoR's switch stays off for good, so its URLs stay its card codes. A page whose route param already equals slug renders; any other known key (the id, a history slug, an alias) redirects to it, so a card whose slug equals its id never redirects to itself.

The catalog export (#2193) writes it only for a switched-on game and only when it differs from id, so an absent slug means the id: always read it through cardSlugOf (@turny/game-adapters).
namestringDisplay name in the catalog locale.
setCodestringSet of the card, or of its default printing ("set1", "sv2", "OGN").
collectible?booleanFalse for cards that can't go in a deck (LoR tokens and level-ups).
assets?CardCatalogCardAssetContract[]Images of the card's default printing.
printings?CardPrintingContract[]Every printing of the identity, default printing first (only some on a partial card, see partialPrintings). Absent in LoR.
printingCount?numberLean list files (#1323), which omit printings, partial cards (see partialPrintings) and per-identity core files (#1522): how many printings the full card has. Absent on full cards and in games without printings.
printingSetCodes?string[]Lean list files (#1323), partial cards and per-identity core files: the distinct set codes across the full card's printings, in printing order. Absent on full cards.
printingsFile?stringPer-identity core files (#1522) only: the card's printings file (identities/<id>.printings.<hash8>.json, relative to the locale directory, see cardCatalogIdentityPrintingsFileName), in place of printings. Absent when the printings are inline in the core file.
partialPrintings?booleanTrue on a partial card (the featured-cards bundle, #1330): printings holds only some of the identity's printings (its default printing plus the ones the featured content references), while printingCount / printingSetCodes summarize all of them. Absent on full and list cards.
hasImage?booleanFalse when none of the card's printings has an image in this language. Absent means it has one.
languages?CardLanguageEntry[]Catalog locales that hold real text for this card (#2552). A locale whose entry is only fallback text is absent. Absent on older exports and in single-locale games.
game?TGameDataGame-specific fields; see the per-game *CardGameData type.

Each entry of languages (CardLanguageEntry):

PropertyTypeDescription
localestringCatalog locale ("zh-tw", "de_de"), not an app locale.
statusCardLanguageStatusWhere the text comes from: official (printed) or unofficial (a translation).

Values of a language entry's status (CardLanguageStatus):

MemberValueDescription
Official"official"Printed in this language by the publisher.
Unofficial"unofficial"Real text the publisher did not print in this language: a reconstruction or a translation.

Printings ​

Each entry of printings (CardPrintingContract):

PropertyTypeDescription
idstringPrinting id; deck refs use it ("sv2-11" for Pokémon, "ogn-030-298" for Riftbound).
setCodestringSet the printing belongs to ("sv2", "OGN").
number?stringCollector number within the set.
language?stringLanguage of the printing, when it is not the catalog's own.
releaseDate?stringRelease date as the source gives it ("2023/06/09").
assets?CardCatalogCardAssetContract[]This printing's own images.
variants?CardVariantContract[]Treatments of this printing (foil, alternate art, …).
metadata?JsonObjectExtra per-printing data (rarity, artist, store ids); game-specific.

Each entry of a printing's variants:

PropertyTypeDescription
idstringVariant id, usually <printing id>:<kind> ("ogn-030-298:normal").
kind?stringTreatment kind ("normal", "foil", "alternate_art"); values are per game.
label?stringDisplay label, when the kind alone is not enough.
metadata?JsonObjectExtra per-variant data; game-specific.

Each entry of assets (on the card and on each printing):

PropertyTypeDescription
kindCardAssetKindWhat the image shows: "card" (framed render), "full" (full art), "icon", "banner", "slice", "portrait", …
urlstringImage URL.
format?CardAssetFormatImage format ("webp"), when known.
width?numberWidth in pixels, when known.
height?numberHeight in pixels, when known.
metadata?JsonObjectExtra per-asset data; game-specific.

Game fields (card.game) ​

Everything specific to Hearthstone lives on card.game. Classes, card types, rarities and formats are lower-case tokens (deathknight, minion); minion types and spell schools keep Blizzard's upper-case tokens (DRAGON, FIRE). Look any of them up in the globals for display names. A stat the card doesn't have (a spell's attack) is left out.

PropertyTypeDescription
dbfIdnumberBlizzard's numeric card id; what deckstrings encode (1004).
cardIdstringHearthstoneJSON / client card id of the default printing ("CORE_CS2_029").
classesHearthstoneClass[]Classes that can play the card; single-class cards carry one (["mage"]), neutrals ["neutral"], dual-class cards two.
cardTypeHearthstoneCardTypeCard type: "minion", "spell", "weapon", "hero" or "location".
cost?numberMana cost.
attack?numberAttack; minions, weapons and some heroes.
health?numberHealth; minions and locations (location "durability" is reported as health upstream).
durability?numberWeapon durability.
armor?numberArmor a hero card grants.
rarity?HearthstoneRarityRarity; absent on cards the source gives none (some non-collectible cards).
races?string[]Minion types, upper-case upstream tokens (["DRAGON"], ["BEAST", "MURLOC"]).
spellSchool?stringSpell school, upper-case upstream token ("FIRE").
runeCost?HearthstoneRuneCostDeath Knight rune cost; absent on cards that need no runes.
mechanics?string[]Upstream mechanic tokens (["BATTLECRY", "TAUNT"]).
referencedTags?string[]Upstream tokens the card's text references without having them (["TAUNT"] on "Give a minion <b>Taunt</b>"). With mechanics, the card's official keyword set — what the keyword filter matches.
setIdstringUpstream set token of the default printing ("CORE", "TITANS"); a globals.sets key.
legalitiesHearthstoneCardLegalitiesLegality per format (see Legalities below).
isProvisional?booleanTrue while the card is announced but not yet released (present upstream but in neither official Standard nor Wild list). Same name and meaning as Pokémon's / Riftbound's, so the Standard (Future) rule reads every game the same way. Absent once released.
copyFamilyRootDbfIdnumberdbfId of the root of the card's copyOfCardId family (a reprint / Core copy points at its original). The identity's continuity anchor; equals dbfId when the card is its own root.
defaultPrintingId?stringId of the default printing; always the first entry of the card's printings.
text?stringRules text with the client's inline markup (<b>Battlecry:</b>, $3).
textPlain?stringRules text as plain text, markup removed.
flavorText?stringFlavor text.
artistName?stringArtist of the default printing.
deckSize?numberThe deck size the card sets while it is in the deck (official deckSizeMod: Prince Renathal 40, Azalina Soulsever 20, Whizbang 1). Absent on cards that keep the standard 30.
sideboard?HearthstoneSideboardRulesThe sideboard the card builds; absent on cards without one.
bannedFromSideboard?booleanTrue when the card may not be put in another card's sideboard; absent otherwise.
touristClass?HearthstoneClassThe class a Tourist lets into the deck (official touristClassId): a Tourist of the hero's class opens its named class. Absent on non-Tourists.
zilliaxModule?HearthstoneZilliaxModuleKindSet on Zilliax Deluxe 3000's sideboard-only modules; absent otherwise.
bundledBy?string[]Catalog identity ids of the cards that bundle this one (the official bundledCardIds reversed: a Fabled card's companions point back at the Fabled card), sorted. A bundled card is never added on its own — it rides in the deck with its bundling card, one copy per copy of it. Absent on cards nothing bundles.
associatedCardRefs?string[]Printing ids (HS card ids) of the cards this one is shown with: the official childIds (tokens it creates, the Zilliax modules, a Fabled card's bundled cards) plus HearthstoneJSON's quest-reward / entourage links, in that order. Only cards the catalog carries; absent when none.

Legalities ​

The legalities object:

PropertyTypeDescription
standardCardLegalityStatusStandard.
wildCardLegalityStatusWild.

Rune cost ​

The runeCost object of a Death Knight card:

PropertyTypeDescription
bloodnumberBlood runes.
frostnumberFrost runes.
unholynumberUnholy runes.

Sideboard rules ​

The sideboard object of a card that builds a sideboard:

PropertyTypeDescription
maxCardsnumberMost cards the sideboard holds (official maxSideboardCards).
subset?stringUpstream token for which cards the sideboard takes (official sideboardSubset: "zilliax-modules", "2-cost-minions", "non-hunter-beast"); absent when any card the deck could run fits (E.T.C.'s band).
ignoresClassbooleanSideboard cards may be of any class (official sideboardIgnoresClass).
countsTowardCopyLimitbooleanSideboard cards count toward the deck's copy limits (official sideboardCardsCountAsMax; Commander Beatrix's pick).

Globals (ctx.globals) ​

The catalog's globals are lookup tables for the values on a card (classes: ["mage"] resolves through ctx.globals.classes.mage), the keyword glossary and the deck code maps.

When globals are available

Globals are passed to ruleset scripts as ctx.globals (the last argument). Calculators may not receive ctx at all, and a ruleset can run without it too. Always check ctx && ctx.globals before using them and fall back to the raw value.

PropertyTypeDescription
classes?Record<string, HearthstoneCatalogClassLookupEntry>Classes by HearthstoneClass value.
rarities?Record<string, HearthstoneCatalogRarityLookupEntry>Rarities by HearthstoneRarity value.
types?Record<string, HearthstoneCatalogTypeLookupEntry>Card types by HearthstoneCardType value.
races?Record<string, HearthstoneCatalogRaceLookupEntry>Minion types by upstream token (a HearthstoneCardGameData.races entry: "MECHANICAL" → Mech): every token a catalog card carries.
spellSchools?Record<string, HearthstoneCatalogSpellSchoolLookupEntry>Spell schools by upstream token (a HearthstoneCardGameData.spellSchool: "FIRE" → Fire): every token a catalog card carries.
formats?Record<string, HearthstoneCatalogFormatLookupEntry>Formats by HearthstoneFormat value (the legalities keys).
sets?Record<string, HearthstoneCatalogSetLookupEntry>Sets by upstream set token ("CORE" → Core).
keywords?Record<string, HearthstoneCatalogKeywordLookupEntry>Keyword glossary by upstream tag (a mechanics / referencedTags token): only the tags that are official keywords on pool cards, labelled and described from Blizzard's keyword metadata in the catalog locale.
printings?Record<string, string>Printing id → owning card identity id ("CORE_CS2_029" → "hs-…"), covering every emitted printing. Only printing ids are keys: identity ids are never self-mapped (a self-map would make the catalog seed create a phantom printing per identity). Same name and meaning as MTG's / Pokémon's globals.printings.
dbfIdToPrintingId?Record<string, string>dbfId (as a string key) → printing id, covering every printing a deckstring can reference ("1004" → "CORE_CS2_029").
defaultPrintingIdByIdentity?Record<string, string>Card identity id → its default printing id (Standard-listed first, then Wild-listed). A Standard deckstring writes this printing's dbfId, because the client judges Standard per dbfId and reads a Legacy copy as Wild (#2630). Optional: catalogs exported before it encode every printing as held.
heroDbfIdToClass?Record<string, HearthstoneClass>Hero card dbfId (base heroes and every skin) → its class, so a deckstring's hero resolves to a class whichever skin it names.

Lookup entries ​

Every table up to keywords maps a key to an entry with these fields:

PropertyTypeDescription
labelstringDisplay name in the catalog locale ("Death Knight").
color?stringDisplay color set by an operator override; usually absent.
icon?string | nullIcon image URL set by an operator override; usually absent.
order?numberSort position in filters and lists, lowest first.
showInFilter?booleanWhether the entry is offered as a filter option; absent means shown.
metadataRef?HearthstoneCatalogMetadataReferenceAnchor an operator override is matched on.

Set entries ​

Entries of sets add:

PropertyTypeDescription
releaseDate?string | nullRelease date (YYYY-MM-DD) when known.
setGroup?string | nullSet group the set belongs to (a rotation year / expansion block), when known.

Keyword entries ​

Entries of keywords add:

PropertyTypeDescription
description?stringReminder text: what the keyword does.

Example card ​

Fireball, with its Core and Legacy printings:

json
{
  "id": "hs-64efa621e6de7e750001",
  "slug": "fireball",
  "name": "Fireball",
  "setCode": "CORE",
  "collectible": true,
  "assets": [
    {
      "kind": "card",
      "url": "https://cdn.turny.gg/cards/hearthstone/assets/hs-64efa621e6de7e750001-card-f1acaa1cd4ffbc04a3058d048a247be1c807374474716f0e6298102ed3319399.webp"
    }
  ],
  "printings": [
    {
      "id": "CORE_CS2_029",
      "setCode": "CORE",
      "metadata": {
        "dbfId": 69501,
        "rarity": "common",
        "craftable": false
      }
    },
    {
      "id": "CS2_029",
      "setCode": "LEGACY",
      "assets": [
        {
          "kind": "card",
          "url": "https://cdn.turny.gg/cards/hearthstone/assets/CS2_029-card-deb20c7165af34e45b116c65a24752984ea07e974f1c0ff39db104829c5a9c07.webp"
        }
      ],
      "metadata": {
        "dbfId": 315,
        "rarity": "free"
      }
    }
  ],
  "hasImage": true,
  "game": {
    "dbfId": 69501,
    "cardId": "CORE_CS2_029",
    "classes": ["mage"],
    "cardType": "spell",
    "cost": 4,
    "rarity": "common",
    "spellSchool": "FIRE",
    "setId": "CORE",
    "legalities": {
      "standard": "legal",
      "wild": "legal"
    },
    "copyFamilyRootDbfId": 315,
    "defaultPrintingId": "CORE_CS2_029",
    "text": "Deal $6 damage.",
    "textPlain": "Deal 6 damage.",
    "flavorText": "This spell is useful for burning things.  If you're looking for spells that toast things, or just warm them a little, you're in the wrong place.",
    "artistName": "Ralph Horsley"
  }
}

Common recipes ​

js
// Calculator: copies at each mana cost, 7+ grouped.
export default function compute(pile, cardsById) {
  const buckets = [0, 0, 0, 0, 0, 0, 0, 0];

  Object.keys(pile).forEach((ref) => {
    const game = (cardsById[ref] && cardsById[ref].game) || {};

    if (typeof game.cost !== "number") {
      return;
    }

    buckets[Math.min(game.cost, 7)] += pile[ref];
  });

  return {
    widgets: [
      {
        kind: "histogram",
        label: "Mana curve",
        buckets: buckets,
        labels: ["0", "1", "2", "3", "4", "5", "6", "7+"],
      },
    ],
  };
}
js
// Calculator: copies per card type.
export default function compute(pile, cardsById) {
  const counts = {};

  Object.keys(pile).forEach((ref) => {
    const game = (cardsById[ref] && cardsById[ref].game) || {};
    const type = game.cardType || "other";

    counts[type] = (counts[type] || 0) + pile[ref];
  });

  return {
    widgets: [
      {
        kind: "donut",
        label: "Card types",
        segments: Object.keys(counts).map((type) => ({
          label: type,
          value: counts[type],
        })),
      },
    ],
  };
}
js
// Card rule: legal in Standard.
export default function validateCard(card) {
  const legalities = (card.game && card.game.legalities) || {};

  if (legalities.standard === "legal") {
    return true;
  }

  return {
    valid: false,
    issues: [{ message: card.name + " is not legal in Standard." }],
  };
}
js
// Card rule: Mage or neutral cards only. Uses the class's display name when globals exist.
export default function validateCard(card, ctx) {
  const classes = (card.game && card.game.classes) || [];

  if (classes.indexOf("mage") !== -1 || classes.indexOf("neutral") !== -1) {
    return true;
  }

  const globals = ctx && ctx.globals;
  const mage =
    globals && globals.classes && globals.classes.mage
      ? globals.classes.mage.label
      : "mage";

  return {
    valid: false,
    issues: [{ message: card.name + " is not a " + mage + " card." }],
  };
}

Turny.gg documentation