ChiriVulpes / scryfall-sdk

A Node.js SDK for https://scryfall.com/docs/api, written in TypeScript.
MIT License
99 stars 16 forks source link

Scry.Cards.collection method unable to handle split card names #71

Closed Joshua-Farr closed 4 months ago

Joshua-Farr commented 4 months ago

Running into issues with sending arrays of split card names using the Cards.collection (...collection: CardIdentifier[]): MagicEmitter method.

Example code:

export const getAllCardImages = async (cardList: string[]) => {
  const collection = cardList.map((card) => {
    return Scry.CardIdentifier.byName(card);
  });
  const cardUrls = await Scry.Cards.collection(...collection).waitForAll();
  return cardUrls;
};

Logging response:

CleanShot 2024-05-22 at 22 08 20@2x
ChiriVulpes commented 4 months ago

It seems like this endpoint is bugged on Scryfall's end, it doesn't currently work for multi-face cards like this — I tested with Struggle // Survive (the actual name), Struggle//Survive, Struggle / Survive, Struggle/Survive, and even tried the same with URI encoding just in case. However, it's a little cursed, but technically it does work if you only search for one face of the card. There may be collisions from doing that, though.

I would recommend if the card names aren't user input, use a different field like ID instead. If you need name because it is user input, you'll need to contact Scryfall because they don't have a public bug tracker.