Endpoint
Request body
The endpoint accepts a JSON object with the following parameters:The number of cards drawn, including the opening hand. For example,
10 represents turn 3 on the play (7 card opening hand + 3 draw steps).The card object for which you want to calculate the probability of playing.
An array of card objects representing your entire deck. Each card in the deck should have the same structure as the
card parameter above.Response
Returns a number between 0 and 1 representing the probability of being able to play the card, or an empty string (
"") if the calculation cannot be performed.A value of 0.847 means there’s an 84.7% chance of being able to play the card by the specified turn.When empty string is returned
The endpoint returns an empty string in the following scenarios:- The target card is a land card (lands don’t require mana to play)
- The number of draws exceeds the deck size (impossible scenario)
- The deck composition cannot support casting the card (not enough mana sources of the required colors)
Examples
cURL
JavaScript (axios)
This example shows how the probability calculation is used in the React frontend:Fetch lands example
Fetch lands add complexity to the calculation. Here’s an example with a fetch land:Error responses
Missing required fields
Request:500 Internal Server Error
The server will log an error if required fields are missing from the card object or if the deck array is not provided.
Invalid data types
Request:500 Internal Server Error
The draws parameter must be a number.
Notes
The probability calculation takes into account:
- Mana cost requirements (both colored and colorless)
- Available mana sources in the deck
- Fetch lands and their ability to search for specific land types
- The number of turns elapsed (derived from draws minus opening hand size)
- Whether you have enough lands to produce the required mana by that turn
Algorithm details
The probability calculation uses a hypergeometric distribution combined with combinatorial analysis to determine all possible hands that would allow you to play the card. The algorithm:- Determines if the card is theoretically playable given the deck composition
- Calculates all possible hand combinations that contain the card and sufficient mana
- Handles fetch lands by considering their ability to search for specific land types
- Uses Vandermonde’s identity to partition probabilities across different fetch land scenarios
- Sums the probabilities of all viable hands
Related resources
API overview
Learn about all available endpoints
Algorithm explanation
Deep dive into the math
