MagicTheGathering/mtg-sdk-javascript

Question: Can I query multiple CMCs?

Opened this issue · 3 comments

How do I fetch cards filtering by multiple cmc? If I do this:
mtg.card.where({set: 'VOW', cmc: '2|3'})
I get a Bad Request error, even though the MTG.io API supports OR operations.

I can do an OR search on colors just fine (red|black), but cmc seems to fail.

Hmmm good question. I read the documentation and the pipe character is the correct way to specify an "or" operation. The error you are seeing is coming directly from the API, even when the pipe is URI encoded:

https://api.magicthegathering.io/v1/cards?set=VOW&cmc=2%7C3

I would suggest reaching to someone on the Discord server. If you can find an API url that works, I can make sure it is supported by the Javascript SDK.

The only thing I can figure out is that cmc is designated as a number in the MTG.io docs, which means the API would reject an OR string. I can work around it by filtering by cmc in the UI, but I don't like loading the extra data and then filtering so much of it out if you want to fetch 1-drop Crimson Vow cards.

I think that's a good hypothesis. String fields work fine:

https://api.magicthegathering.io/v1/cards?name=Virtuous|Vicious