ontehfritz / api.mtgdb.info

Project closing first of August 2015
http://www.mtgdb.info/
MIT License
36 stars 8 forks source link

Allow parameters for 'random' cards #67

Open alotau opened 10 years ago

alotau commented 10 years ago

Would be nice to have the ability to further refine the type of random card that is returned. Currently a random card from a specific set can be returned. Would be nice to request a random card based on other features as well, such as:

color, type, legality, artist, etc...

Some example requests might be:

A random blue card that is currently in Standard. A random creature with CMC over 5. A random green enchantment. A random artifact by Artist X.

Etc.

ontehfritz commented 10 years ago

:+1:

alotau commented 10 years ago

If there was a way to do a "double query" efficiently, we could use the "complex query" for this task. For example, if I knew the result of my complex query had 71 results, I could use the "start" and "limit" params to grab any one of those, likely just generating a random number from 1 to 71 for "start" and setting limit to '1'.

Might there be a way to query for the size of a result set without actually generating and downloading the entire result set?

ontehfritz commented 10 years ago

Alright man I hooked this up for you, so you can try it and let me know, if you append &total=true, it will return just the total result number:

http://api.mtgdb.info/search/?q=color%20eq%20blue&total=true

Let me know how this works, for you. It should allow you to build into the java api this functionality.

Let me know if this works well. Then we will work from there.