Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: Can I query multiple CMCs? #28

Open
rendermouse opened this issue Dec 11, 2021 · 3 comments
Open

Question: Can I query multiple CMCs? #28

rendermouse opened this issue Dec 11, 2021 · 3 comments

Comments

@rendermouse
Copy link

rendermouse commented Dec 11, 2021

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.

@raineorshine
Copy link
Collaborator

raineorshine commented Dec 11, 2021

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.

@rendermouse
Copy link
Author

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.

@raineorshine
Copy link
Collaborator

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants