Skip to content

MTGO name lookup fallback and printed_name typing #44

Description

@lucasfeliciano

Hi! Thanks for maintaining @scryfall/api-types.

I’m trying to confirm expected behavior around MTGO card names and printed_name, and whether my typing/call pattern is correct.

Use case

I import card names coming from MTGO. Some cards (example: Spider-Man set cards) have names that differ from the canonical Scryfall name.

When I search those MTGO names directly using /cards/collection (with { "name": "..." }), lookup may fail.
My fallback is:

  1. call /cards/named?fuzzy=<name>
  2. verify that printed_name equals the original MTGO name I searched for

Some cards come with printed_name, while others do not.

Typing context

printed_name is defined in ScryfallCardFields.Print.Localization and composed through Print.CardFaceSpecific.
Because ScryfallCard.Any is a broad union, direct card.printed_name access is rejected unless narrowed/cast.

My current workaround is to cast ScryfallCard.Any to include optional printed_name when needed:

import type { ScryfallCard } from "@scryfall/api-types";
function getPrintedName(card: ScryfallCard.Any): string | undefined {
  return (card as ScryfallCard.Any & { printed_name?: string }).printed_name;
}

What I’d like to confirm

  1. Is it expected that MTGO names are not always searchable via /cards/collection and that we need to fallback to /cards/named?fuzzy?
  2. Is using fuzzy + printed_name === inputName a recommended validation strategy for alternate/MTGO names?
  3. Is there a preferred narrowing pattern/helper type guard for reading printed_name from ScryfallCard.Any?

If useful, I can provide concrete card examples and request/response payloads.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions