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:
- call
/cards/named?fuzzy=<name>
- 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
- Is it expected that MTGO names are not always searchable via
/cards/collection and that we need to fallback to /cards/named?fuzzy?
- Is using
fuzzy + printed_name === inputName a recommended validation strategy for alternate/MTGO names?
- 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.
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:
/cards/named?fuzzy=<name>printed_nameequals the original MTGO name I searched forSome cards come with
printed_name, while others do not.Typing context
printed_nameis defined inScryfallCardFields.Print.Localizationand composed throughPrint.CardFaceSpecific.Because
ScryfallCard.Anyis a broad union, directcard.printed_nameaccess is rejected unless narrowed/cast.My current workaround is to cast
ScryfallCard.Anyto include optionalprinted_namewhen needed:What I’d like to confirm
/cards/collectionand that we need to fallback to/cards/named?fuzzy?fuzzy+printed_name === inputNamea recommended validation strategy for alternate/MTGO names?printed_namefromScryfallCard.Any?If useful, I can provide concrete card examples and request/response payloads.