Blog ·
What “one response shape” means across every game
What stays identical in every game of the API (envelope, card fields, errors, pagination, credits), what varies inside attributes, and how to render it.
The home page of this site says "one response shape". This article spells out what that covers and where it stops, so you can decide what to hard-code and what to read at run time.
What is identical in every game
- The envelope. A list is { data, meta, links }, one object is { data }, an error is { error: { code, message, details, request_id } }.
- The fields of a card: id, game, set, number, name, rarity, supertype, attributes, image_url, languages, external_ids, version and updated_at. Same names and same types, whatever the game.
- Sets and sealed products, likewise: one set of fields each, listed on the coverage page.
- Pagination: limit up to 250, then links.next until it is null.
- Credits and headers: the same cost per route and the same X-Credits-Cost and X-Quota-Remaining on every response.
- Prices: one quote object, with source, variant, language, condition, printing, region, eu_only, price and as_of.
What varies: supertype
supertype holds the card type in the words of the game: Effect Monster or Counter Trap in Yu-Gi-Oh!, Digi-Egg, Digimon, Tamer or Option in Digimon, Leader, Base, Unit, Event or Upgrade in Star Wars: Unlimited. They are the game’s own categories, not a vocabulary shared across games, and supertype can be null.
What varies: attributes
attributes holds the rules data of the card. The keys depend on the game:
| Game | Keys | Notes |
|---|---|---|
| Pokémon | hp, types, subtypes | types are the Pokémon types. |
| Yu-Gi-Oh! | attack, defense, monsterType, types | types holds the attribute, such as LIGHT or DARK. |
| One Piece | types | The colours of the card. |
| Digimon | level, form, digimonTypes, types | form runs from In-Training and Rookie up. |
| Riftbound | types | The domains. A dual-domain card carries both. |
| Force of Will | types | The attribute: Light, Fire, Water, Wind or Darkness. |
types is the one key several games share, and it means something different in each. Do not build a cross-game filter on it without the game next to it.
Two rules hold everywhere. A key the card does not have is left out, not sent as null. A card with no rules data at all has attributes set to null. Some games carry little rules data today: Cardfight!! Vanguard cards, for example, carry number, name, rarity and image.
Rendering it without a case per game
Render the shared fields the same way for every game. For attributes, keep a small table of renderers for the games your product cares about, and a fallback for every other game, including the ones the API has not added yet.
interface Card {
id: string;
game: string;
set: { id: string; code: string; name: string };
number: string;
name: string;
rarity: string | null;
supertype: string | null;
attributes: Record<string, unknown> | null;
image_url: string | null;
external_ids: { cardmarket: number | null; tcgplayer: number | null };
version: number;
}
type Row = [label: string, value: string];
const text = (v: unknown): string => (Array.isArray(v) ? v.join(', ') : v == null ? '' : String(v));
const RENDERERS: Record<string, (a: Record<string, unknown>) => Row[]> = {
pokemon: (a) => [['HP', text(a.hp)], ['Types', text(a.types)]],
yugioh: (a) => [['ATK', text(a.attack)], ['DEF', text(a.defense)], ['Type', text(a.monsterType)]],
digimon: (a) => [['Level', text(a.level)], ['Form', text(a.form)]],
};
// Any other game: print what is there, key by key.
const fallback = (a: Record<string, unknown>): Row[] => Object.entries(a).map(([k, v]) => [k, text(v)]);
export function details(card: Card): Row[] {
if (!card.attributes) return [];
const render = RENDERERS[card.game] ?? fallback;
return render(card.attributes).filter(([, value]) => value !== '');
}The filter at the end matters because keys are left out when a card does not have them: a Spell Card has no ATK, and the row should disappear rather than show an empty value.
What is not uniform, and where to read it
- Sealed products exist for some games only. GET /v1/games returns the sealed count of each game: read it instead of showing an empty tab.
- Price coverage differs by game and by source. GET /v1/prices/coverage is public and says, per game and source, how many items have a quote.
- Cardmarket ids are partial in games where TCGplayer and Cardmarket split finishes differently.
- Print regions: Pokémon has WEST and EAST sets. For another game, check /v1/sets?region=EAST before relying on it.
- Depth of rules data: some games carry the full set of fields above, others only number, name, rarity, type and image.
A game you have never seen
Game ids come from /v1/games, and an unknown game= is answered with a 400 that lists the valid ids. If your app loads that list at start-up, renders the shared fields and falls back to printing attributes, a game added to the API shows up in your product with no code change. That is the practical meaning of one response shape.
Published · Atom feed