{
 "openapi": "3.1.0",
 "info": {
  "title": "DeckCosmos API",
  "version": "1.1.0",
  "summary": "Card synergies, deck building and deck analysis for Magic: The Gathering, focused on Commander.",
  "description": "The same tools as deckcosmos.com: search cards, explain synergies, build complete decks at a chosen power bracket, check and simulate decks, find combos and look up the Comprehensive Rules. Free, no key. Every tool is also available over MCP at https://deckcosmos.com/mcp. Docs: https://deckcosmos.com/developers/.\n\nPlease keep it reasonable: about 30 requests a minute per client (builds, checks and simulations count 4). Card data and images: Scryfall. Combos: Commander Spellbook. Unofficial Fan Content permitted under the Wizards of the Coast Fan Content Policy; not approved or endorsed by Wizards.",
  "contact": {
   "url": "https://deckcosmos.com/developers/"
  }
 },
 "servers": [
  {
   "url": "https://deckcosmos.com"
  }
 ],
 "externalDocs": {
  "url": "https://deckcosmos.com/developers/",
  "description": "Developer docs and MCP setup"
 },
 "paths": {
  "/api/v1/search": {
   "get": {
    "tags": [
     "Search cards"
    ],
    "description": "Find cards with a plain-words query, the same as the website's card finder. Words are read as creature types (\"rat\"), keywords (\"deathtouch\", \"first strike\"), card types (\"artifact\", \"legendary\"), colors (\"black\") or rules-text words (\"sacrifice\", \"draw\"); e.g. \"elf lord\", \"black rat deathtouch\", \"artifact sacrifice draw\". Optionally filter by role (what the card does, see reference/roles), format, color identity and price. Sorted by popularity unless asked otherwise.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "query": {
           "type": "string",
           "description": "The query as given."
          },
          "understood_as": {
           "type": "object",
           "description": "How the query words were read: creature_types, keywords, card_types, colors, text.",
           "additionalProperties": {
            "type": "array",
            "items": {
             "type": "string"
            }
           }
          },
          "role": {
           "type": [
            "string",
            "null"
           ],
           "description": "Role filter applied."
          },
          "format": {
           "type": "string",
           "description": "Format filter applied."
          },
          "total": {
           "type": "integer",
           "description": "Matching cards in all."
          },
          "offset": {
           "type": "integer",
           "description": "Offset of the first card returned."
          },
          "cards": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card name."
             },
             "mana_cost": {
              "type": "string",
              "description": "Mana cost, e.g. \"{2}{B}{B}\"."
             },
             "type": {
              "type": "string",
              "description": "Type line."
             },
             "color_identity": {
              "type": "string",
              "description": "Color identity letters in WUBRG order, e.g. \"BG\"; \"\" for colorless."
             },
             "price_usd": {
              "type": [
               "number",
               "null"
              ],
              "description": "Approximate price in USD (Scryfall), or null if unknown."
             },
             "mana_value": {
              "type": "number",
              "description": "Mana value."
             },
             "oracle_text": {
              "type": "string",
              "description": "Rules text."
             },
             "roles": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Role keys (what the card does)."
             },
             "popularity_rank": {
              "type": [
               "integer",
               "null"
              ],
              "description": "Rank by how many decks play it (1 = most)."
             }
            },
            "required": [
             "name",
             "mana_cost",
             "type",
             "color_identity",
             "price_usd",
             "mana_value",
             "oracle_text",
             "roles",
             "popularity_rank"
            ]
           },
           "description": "Matching cards."
          }
         },
         "required": [
          "query",
          "total",
          "cards"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "search_cards_get",
    "summary": "Search cards",
    "parameters": [
     {
      "name": "query",
      "in": "query",
      "required": false,
      "description": "Plain words, e.g. \"goblin haste\" or \"enchantment draw a card\".",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "role",
      "in": "query",
      "required": false,
      "description": "Only cards with this role key, e.g. sac_outlet, token_payoff, landfall (see reference what=roles).",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "sort",
      "in": "query",
      "required": false,
      "description": "Default popularity (most-played first).",
      "schema": {
       "type": "string",
       "enum": [
        "popularity",
        "name",
        "mv"
       ]
      }
     },
     {
      "name": "format",
      "in": "query",
      "required": false,
      "description": "Format whose legal cards are considered. Default: any.",
      "schema": {
       "type": "string",
       "enum": [
        "commander",
        "standard",
        "pioneer",
        "modern",
        "legacy",
        "vintage",
        "pauper",
        "any"
       ]
      }
     },
     {
      "name": "colors",
      "in": "query",
      "required": false,
      "description": "Only cards within this color identity, e.g. \"BG\". Empty = any.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "max_price",
      "in": "query",
      "required": false,
      "description": "Only cards at or under this USD price.",
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Default 20.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100
      }
     },
     {
      "name": "offset",
      "in": "query",
      "required": false,
      "description": "For paging. Default 0.",
      "schema": {
       "type": "integer",
       "minimum": 0
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Search cards"
    ],
    "description": "Find cards with a plain-words query, the same as the website's card finder. Words are read as creature types (\"rat\"), keywords (\"deathtouch\", \"first strike\"), card types (\"artifact\", \"legendary\"), colors (\"black\") or rules-text words (\"sacrifice\", \"draw\"); e.g. \"elf lord\", \"black rat deathtouch\", \"artifact sacrifice draw\". Optionally filter by role (what the card does, see reference/roles), format, color identity and price. Sorted by popularity unless asked otherwise.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "query": {
           "type": "string",
           "description": "The query as given."
          },
          "understood_as": {
           "type": "object",
           "description": "How the query words were read: creature_types, keywords, card_types, colors, text.",
           "additionalProperties": {
            "type": "array",
            "items": {
             "type": "string"
            }
           }
          },
          "role": {
           "type": [
            "string",
            "null"
           ],
           "description": "Role filter applied."
          },
          "format": {
           "type": "string",
           "description": "Format filter applied."
          },
          "total": {
           "type": "integer",
           "description": "Matching cards in all."
          },
          "offset": {
           "type": "integer",
           "description": "Offset of the first card returned."
          },
          "cards": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card name."
             },
             "mana_cost": {
              "type": "string",
              "description": "Mana cost, e.g. \"{2}{B}{B}\"."
             },
             "type": {
              "type": "string",
              "description": "Type line."
             },
             "color_identity": {
              "type": "string",
              "description": "Color identity letters in WUBRG order, e.g. \"BG\"; \"\" for colorless."
             },
             "price_usd": {
              "type": [
               "number",
               "null"
              ],
              "description": "Approximate price in USD (Scryfall), or null if unknown."
             },
             "mana_value": {
              "type": "number",
              "description": "Mana value."
             },
             "oracle_text": {
              "type": "string",
              "description": "Rules text."
             },
             "roles": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Role keys (what the card does)."
             },
             "popularity_rank": {
              "type": [
               "integer",
               "null"
              ],
              "description": "Rank by how many decks play it (1 = most)."
             }
            },
            "required": [
             "name",
             "mana_cost",
             "type",
             "color_identity",
             "price_usd",
             "mana_value",
             "oracle_text",
             "roles",
             "popularity_rank"
            ]
           },
           "description": "Matching cards."
          }
         },
         "required": [
          "query",
          "total",
          "cards"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "search_cards",
    "summary": "Search cards (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "query": {
          "type": "string",
          "description": "Plain words, e.g. \"goblin haste\" or \"enchantment draw a card\"."
         },
         "role": {
          "type": "string",
          "description": "Only cards with this role key, e.g. sac_outlet, token_payoff, landfall (see reference what=roles)."
         },
         "sort": {
          "type": "string",
          "enum": [
           "popularity",
           "name",
           "mv"
          ],
          "description": "Default popularity (most-played first)."
         },
         "format": {
          "type": "string",
          "enum": [
           "commander",
           "standard",
           "pioneer",
           "modern",
           "legacy",
           "vintage",
           "pauper",
           "any"
          ],
          "description": "Format whose legal cards are considered. Default: any."
         },
         "colors": {
          "type": "string",
          "description": "Only cards within this color identity, e.g. \"BG\". Empty = any."
         },
         "max_price": {
          "type": "number",
          "description": "Only cards at or under this USD price."
         },
         "limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "description": "Default 20."
         },
         "offset": {
          "type": "integer",
          "minimum": 0,
          "description": "For paging. Default 0."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/card": {
   "get": {
    "tags": [
     "Card details"
    ],
    "description": "Everything DeckCosmos knows about one card: rules text, type, color identity, legality, price, popularity rank, Game Changer status, its roles (what it provides and rewards), whether it can be a commander, and for commanders a build plan (strategy summary, key cards, finishers). Accepts exact names, front-face names of double-faced cards, and close spellings.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "name": {
           "type": "string",
           "description": "Card name."
          },
          "mana_cost": {
           "type": "string",
           "description": "Mana cost."
          },
          "mana_value": {
           "type": "number",
           "description": "Mana value."
          },
          "type": {
           "type": "string",
           "description": "Type line."
          },
          "oracle_text": {
           "type": "string",
           "description": "Rules text (both faces for double-faced cards)."
          },
          "color_identity": {
           "type": "string",
           "description": "Color identity letters in WUBRG order, e.g. \"BG\"; \"\" for colorless."
          },
          "keywords": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Keyword abilities."
          },
          "power": {
           "type": [
            "integer",
            "string",
            "null"
           ],
           "description": "Power, for creatures."
          },
          "legal_in": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Formats it is legal in."
          },
          "price_usd": {
           "type": [
            "number",
            "null"
           ],
           "description": "Approximate price in USD (Scryfall), or null if unknown."
          },
          "popularity_rank": {
           "type": [
            "integer",
            "null"
           ],
           "description": "Rank by how many decks play it (1 = most)."
          },
          "game_changer": {
           "type": "boolean",
           "description": "On the official Commander Game Changers list."
          },
          "can_be_commander": {
           "type": "boolean",
           "description": "Can be a Commander deck's commander."
          },
          "roles": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Role keys: what the card provides and rewards (see reference what=roles)."
          },
          "image": {
           "type": [
            "string",
            "null"
           ],
           "description": "Card image URL (Scryfall)."
          },
          "page_url": {
           "type": "string",
           "description": "The card's page on deckcosmos.com."
          },
          "app_url": {
           "type": "string",
           "description": "The card in the deckcosmos.com synergy map."
          },
          "buy_url": {
           "type": "string",
           "description": "The card on TCGplayer (product search)."
          },
          "build_plan": {
           "type": [
            "object",
            "null"
           ],
           "description": "For commanders: the strategy DeckCosmos builds around.",
           "properties": {
            "summary": {
             "type": "string",
             "description": "How the deck plays."
            },
            "key_cards": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Cards the strategy wants."
            },
            "finishers": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Ways it wins."
            },
            "creatures": {
             "type": [
              "integer",
              "null"
             ],
             "description": "Target creature count."
            },
            "lands": {
             "type": [
              "integer",
              "null"
             ],
             "description": "Target land count."
            },
            "tribe": {
             "type": [
              "string",
              "null"
             ],
             "description": "Creature type it cares about, if any."
            }
           },
           "required": [
            "summary"
           ]
          },
          "combos_count": {
           "type": "integer",
           "description": "Known combos including the card (see find_combos)."
          }
         },
         "required": [
          "name",
          "type",
          "color_identity",
          "can_be_commander",
          "roles"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "get_card_get",
    "summary": "Card details",
    "parameters": [
     {
      "name": "name",
      "in": "query",
      "required": true,
      "description": "Card name, e.g. \"Krenko, Mob Boss\".",
      "schema": {
       "type": "string"
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Card details"
    ],
    "description": "Everything DeckCosmos knows about one card: rules text, type, color identity, legality, price, popularity rank, Game Changer status, its roles (what it provides and rewards), whether it can be a commander, and for commanders a build plan (strategy summary, key cards, finishers). Accepts exact names, front-face names of double-faced cards, and close spellings.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "name": {
           "type": "string",
           "description": "Card name."
          },
          "mana_cost": {
           "type": "string",
           "description": "Mana cost."
          },
          "mana_value": {
           "type": "number",
           "description": "Mana value."
          },
          "type": {
           "type": "string",
           "description": "Type line."
          },
          "oracle_text": {
           "type": "string",
           "description": "Rules text (both faces for double-faced cards)."
          },
          "color_identity": {
           "type": "string",
           "description": "Color identity letters in WUBRG order, e.g. \"BG\"; \"\" for colorless."
          },
          "keywords": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Keyword abilities."
          },
          "power": {
           "type": [
            "integer",
            "string",
            "null"
           ],
           "description": "Power, for creatures."
          },
          "legal_in": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Formats it is legal in."
          },
          "price_usd": {
           "type": [
            "number",
            "null"
           ],
           "description": "Approximate price in USD (Scryfall), or null if unknown."
          },
          "popularity_rank": {
           "type": [
            "integer",
            "null"
           ],
           "description": "Rank by how many decks play it (1 = most)."
          },
          "game_changer": {
           "type": "boolean",
           "description": "On the official Commander Game Changers list."
          },
          "can_be_commander": {
           "type": "boolean",
           "description": "Can be a Commander deck's commander."
          },
          "roles": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Role keys: what the card provides and rewards (see reference what=roles)."
          },
          "image": {
           "type": [
            "string",
            "null"
           ],
           "description": "Card image URL (Scryfall)."
          },
          "page_url": {
           "type": "string",
           "description": "The card's page on deckcosmos.com."
          },
          "app_url": {
           "type": "string",
           "description": "The card in the deckcosmos.com synergy map."
          },
          "buy_url": {
           "type": "string",
           "description": "The card on TCGplayer (product search)."
          },
          "build_plan": {
           "type": [
            "object",
            "null"
           ],
           "description": "For commanders: the strategy DeckCosmos builds around.",
           "properties": {
            "summary": {
             "type": "string",
             "description": "How the deck plays."
            },
            "key_cards": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Cards the strategy wants."
            },
            "finishers": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Ways it wins."
            },
            "creatures": {
             "type": [
              "integer",
              "null"
             ],
             "description": "Target creature count."
            },
            "lands": {
             "type": [
              "integer",
              "null"
             ],
             "description": "Target land count."
            },
            "tribe": {
             "type": [
              "string",
              "null"
             ],
             "description": "Creature type it cares about, if any."
            }
           },
           "required": [
            "summary"
           ]
          },
          "combos_count": {
           "type": "integer",
           "description": "Known combos including the card (see find_combos)."
          }
         },
         "required": [
          "name",
          "type",
          "color_identity",
          "can_be_commander",
          "roles"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "get_card",
    "summary": "Card details (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "name": {
          "type": "string",
          "description": "Card name, e.g. \"Krenko, Mob Boss\"."
         }
        },
        "required": [
         "name"
        ]
       }
      }
     }
    }
   }
  },
  "/api/v1/synergies": {
   "get": {
    "tags": [
     "Synergies for a card"
    ],
    "description": "The cards that work best with a given card, ranked, each with the reason it works (\"Ashnod's Altar sacrifices creatures on demand; Blood Artist pays off every time a creature dies\"). The website's synergy map for one card. Synergies are mechanical (roles that fit together, tribes, keyword payoffs, known combos), weighted by popularity.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "card": {
           "type": "string",
           "description": "The card."
          },
          "format": {
           "type": "string",
           "description": "Format considered."
          },
          "same_colors": {
           "type": "boolean",
           "description": "Limited to the card's color identity."
          },
          "synergies": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card name."
             },
             "mana_cost": {
              "type": "string",
              "description": "Mana cost, e.g. \"{2}{B}{B}\"."
             },
             "type": {
              "type": "string",
              "description": "Type line."
             },
             "color_identity": {
              "type": "string",
              "description": "Color identity letters in WUBRG order, e.g. \"BG\"; \"\" for colorless."
             },
             "price_usd": {
              "type": [
               "number",
               "null"
              ],
              "description": "Approximate price in USD (Scryfall), or null if unknown."
             },
             "score": {
              "type": "number",
              "description": "Synergy strength (higher = stronger)."
             },
             "categories": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Synergy category keys."
             },
             "why": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Why the two cards work together."
             }
            },
            "required": [
             "name",
             "mana_cost",
             "type",
             "color_identity",
             "price_usd",
             "score",
             "categories",
             "why"
            ]
           },
           "description": "Best partners first."
          },
          "app_url": {
           "type": "string",
           "description": "This view on deckcosmos.com."
          }
         },
         "required": [
          "card",
          "synergies"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "get_synergies_get",
    "summary": "Synergies for a card",
    "parameters": [
     {
      "name": "card",
      "in": "query",
      "required": true,
      "description": "Card name.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "format",
      "in": "query",
      "required": false,
      "description": "Format whose legal cards are considered. Default: commander if the card is legal there, else any.",
      "schema": {
       "type": "string",
       "enum": [
        "commander",
        "standard",
        "pioneer",
        "modern",
        "legacy",
        "vintage",
        "pauper",
        "any"
       ]
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Default 20.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100
      }
     },
     {
      "name": "same_colors",
      "in": "query",
      "required": false,
      "description": "Only cards within the card's color identity (useful for a commander). Default false.",
      "schema": {
       "type": "boolean"
      }
     },
     {
      "name": "categories",
      "in": "query",
      "required": false,
      "description": "Only these synergy categories (keys from reference what=categories), e.g. [\"sacrifice\", \"tokens\"]. Repeat the parameter or separate values with |.",
      "schema": {
       "type": "array",
       "items": {
        "type": "string"
       }
      },
      "style": "form",
      "explode": true
     }
    ]
   },
   "post": {
    "tags": [
     "Synergies for a card"
    ],
    "description": "The cards that work best with a given card, ranked, each with the reason it works (\"Ashnod's Altar sacrifices creatures on demand; Blood Artist pays off every time a creature dies\"). The website's synergy map for one card. Synergies are mechanical (roles that fit together, tribes, keyword payoffs, known combos), weighted by popularity.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "card": {
           "type": "string",
           "description": "The card."
          },
          "format": {
           "type": "string",
           "description": "Format considered."
          },
          "same_colors": {
           "type": "boolean",
           "description": "Limited to the card's color identity."
          },
          "synergies": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card name."
             },
             "mana_cost": {
              "type": "string",
              "description": "Mana cost, e.g. \"{2}{B}{B}\"."
             },
             "type": {
              "type": "string",
              "description": "Type line."
             },
             "color_identity": {
              "type": "string",
              "description": "Color identity letters in WUBRG order, e.g. \"BG\"; \"\" for colorless."
             },
             "price_usd": {
              "type": [
               "number",
               "null"
              ],
              "description": "Approximate price in USD (Scryfall), or null if unknown."
             },
             "score": {
              "type": "number",
              "description": "Synergy strength (higher = stronger)."
             },
             "categories": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Synergy category keys."
             },
             "why": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Why the two cards work together."
             }
            },
            "required": [
             "name",
             "mana_cost",
             "type",
             "color_identity",
             "price_usd",
             "score",
             "categories",
             "why"
            ]
           },
           "description": "Best partners first."
          },
          "app_url": {
           "type": "string",
           "description": "This view on deckcosmos.com."
          }
         },
         "required": [
          "card",
          "synergies"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "get_synergies",
    "summary": "Synergies for a card (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "card": {
          "type": "string",
          "description": "Card name."
         },
         "format": {
          "type": "string",
          "enum": [
           "commander",
           "standard",
           "pioneer",
           "modern",
           "legacy",
           "vintage",
           "pauper",
           "any"
          ],
          "description": "Format whose legal cards are considered. Default: commander if the card is legal there, else any."
         },
         "limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "description": "Default 20."
         },
         "same_colors": {
          "type": "boolean",
          "description": "Only cards within the card's color identity (useful for a commander). Default false."
         },
         "categories": {
          "type": "array",
          "items": {
           "type": "string"
          },
          "description": "Only these synergy categories (keys from reference what=categories), e.g. [\"sacrifice\", \"tokens\"]."
         }
        },
        "required": [
         "card"
        ]
       }
      }
     }
    }
   }
  },
  "/api/v1/deck-synergies": {
   "get": {
    "tags": [
     "Synergies within a group of cards"
    ],
    "description": "For a group of cards (a deck idea, a pile of favorites): which pairs work together and why, and the cards that work with several of them at once, the best additions. The website's deck tray view.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "format": {
           "type": "string",
           "description": "Format considered."
          },
          "cards": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "The cards, as recognized."
          },
          "pairs_with_synergy": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The two cards."
             },
             "categories": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Synergy category keys."
             },
             "why": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Why they work together."
             }
            },
            "required": [
             "cards",
             "categories",
             "why"
            ]
           },
           "description": "Pairs within the group that work together."
          },
          "pairs_without": {
           "type": "integer",
           "description": "Pairs with no synergy found."
          },
          "suggestions": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card name."
             },
             "mana_cost": {
              "type": "string",
              "description": "Mana cost, e.g. \"{2}{B}{B}\"."
             },
             "type": {
              "type": "string",
              "description": "Type line."
             },
             "color_identity": {
              "type": "string",
              "description": "Color identity letters in WUBRG order, e.g. \"BG\"; \"\" for colorless."
             },
             "price_usd": {
              "type": [
               "number",
               "null"
              ],
              "description": "Approximate price in USD (Scryfall), or null if unknown."
             },
             "score": {
              "type": "number",
              "description": "Combined synergy with the group."
             },
             "works_with": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Group cards it works with."
             },
             "why": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Reasons."
             }
            },
            "required": [
             "name",
             "mana_cost",
             "type",
             "color_identity",
             "price_usd",
             "score",
             "works_with",
             "why"
            ]
           },
           "description": "Best additions: cards that work with several of the group."
          },
          "app_url": {
           "type": "string",
           "description": "This group in the deckcosmos.com deck tray."
          }
         },
         "required": [
          "cards",
          "pairs_with_synergy",
          "suggestions"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "deck_synergies_get",
    "summary": "Synergies within a group of cards",
    "parameters": [
     {
      "name": "cards",
      "in": "query",
      "required": true,
      "description": "Card names. Repeat the parameter or separate values with |.",
      "schema": {
       "type": "array",
       "items": {
        "type": "string"
       }
      },
      "style": "form",
      "explode": true
     },
     {
      "name": "format",
      "in": "query",
      "required": false,
      "description": "Format whose legal cards are considered. Default: commander.",
      "schema": {
       "type": "string",
       "enum": [
        "commander",
        "standard",
        "pioneer",
        "modern",
        "legacy",
        "vintage",
        "pauper",
        "any"
       ]
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Suggestions to return. Default 20.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100
      }
     },
     {
      "name": "same_colors",
      "in": "query",
      "required": false,
      "description": "Only suggest cards within the group's combined colors. Default false.",
      "schema": {
       "type": "boolean"
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Synergies within a group of cards"
    ],
    "description": "For a group of cards (a deck idea, a pile of favorites): which pairs work together and why, and the cards that work with several of them at once, the best additions. The website's deck tray view.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "format": {
           "type": "string",
           "description": "Format considered."
          },
          "cards": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "The cards, as recognized."
          },
          "pairs_with_synergy": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The two cards."
             },
             "categories": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Synergy category keys."
             },
             "why": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Why they work together."
             }
            },
            "required": [
             "cards",
             "categories",
             "why"
            ]
           },
           "description": "Pairs within the group that work together."
          },
          "pairs_without": {
           "type": "integer",
           "description": "Pairs with no synergy found."
          },
          "suggestions": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card name."
             },
             "mana_cost": {
              "type": "string",
              "description": "Mana cost, e.g. \"{2}{B}{B}\"."
             },
             "type": {
              "type": "string",
              "description": "Type line."
             },
             "color_identity": {
              "type": "string",
              "description": "Color identity letters in WUBRG order, e.g. \"BG\"; \"\" for colorless."
             },
             "price_usd": {
              "type": [
               "number",
               "null"
              ],
              "description": "Approximate price in USD (Scryfall), or null if unknown."
             },
             "score": {
              "type": "number",
              "description": "Combined synergy with the group."
             },
             "works_with": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Group cards it works with."
             },
             "why": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Reasons."
             }
            },
            "required": [
             "name",
             "mana_cost",
             "type",
             "color_identity",
             "price_usd",
             "score",
             "works_with",
             "why"
            ]
           },
           "description": "Best additions: cards that work with several of the group."
          },
          "app_url": {
           "type": "string",
           "description": "This group in the deckcosmos.com deck tray."
          }
         },
         "required": [
          "cards",
          "pairs_with_synergy",
          "suggestions"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "deck_synergies",
    "summary": "Synergies within a group of cards (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "cards": {
          "type": "array",
          "items": {
           "type": "string"
          },
          "minItems": 2,
          "maxItems": 100,
          "description": "Card names."
         },
         "format": {
          "type": "string",
          "enum": [
           "commander",
           "standard",
           "pioneer",
           "modern",
           "legacy",
           "vintage",
           "pauper",
           "any"
          ],
          "description": "Format whose legal cards are considered. Default: commander."
         },
         "limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "description": "Suggestions to return. Default 20."
         },
         "same_colors": {
          "type": "boolean",
          "description": "Only suggest cards within the group's combined colors. Default false."
         }
        },
        "required": [
         "cards"
        ]
       }
      }
     }
    }
   }
  },
  "/api/v1/combos": {
   "get": {
    "tags": [
     "Find combos"
    ],
    "description": "Known combos from Commander Spellbook. With \"card\": the most-played combos that include it. With \"cards\" (a deck or a pile): the combos already complete in it, and the ones a single added card would complete. Each combo lists its cards, results (e.g. \"Infinite mana\"), popularity and a link to its steps.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "card": {
           "type": "string",
           "description": "With \"card\": the card."
          },
          "total": {
           "type": "integer",
           "description": "With \"card\": its known combos in all."
          },
          "combos": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "With \"card\": its most-played combos."
          },
          "cards": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "With \"cards\": the cards, as recognized."
          },
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "With \"cards\": the commander."
          },
          "complete_combos": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "With \"cards\": combos complete in the list."
          },
          "one_card_away": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "add": {
              "type": "string",
              "description": "The card that would complete it."
             },
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "add",
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "With \"cards\": combos one added card would complete (within the colors)."
          },
          "source": {
           "type": "string",
           "description": "Data source."
          }
         },
         "required": [
          "source"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "find_combos_get",
    "summary": "Find combos",
    "parameters": [
     {
      "name": "card",
      "in": "query",
      "required": false,
      "description": "One card: its combos.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "cards",
      "in": "query",
      "required": false,
      "description": "A list of card names: complete and one-card-away combos. Repeat the parameter or separate values with |.",
      "schema": {
       "type": "array",
       "items": {
        "type": "string"
       }
      },
      "style": "form",
      "explode": true
     },
     {
      "name": "commander",
      "in": "query",
      "required": false,
      "description": "The commander, for combos that need a specific commander.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "required": false,
      "description": "Default 20.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 100
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Find combos"
    ],
    "description": "Known combos from Commander Spellbook. With \"card\": the most-played combos that include it. With \"cards\" (a deck or a pile): the combos already complete in it, and the ones a single added card would complete. Each combo lists its cards, results (e.g. \"Infinite mana\"), popularity and a link to its steps.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "card": {
           "type": "string",
           "description": "With \"card\": the card."
          },
          "total": {
           "type": "integer",
           "description": "With \"card\": its known combos in all."
          },
          "combos": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "With \"card\": its most-played combos."
          },
          "cards": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "With \"cards\": the cards, as recognized."
          },
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "With \"cards\": the commander."
          },
          "complete_combos": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "With \"cards\": combos complete in the list."
          },
          "one_card_away": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "add": {
              "type": "string",
              "description": "The card that would complete it."
             },
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "add",
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "With \"cards\": combos one added card would complete (within the colors)."
          },
          "source": {
           "type": "string",
           "description": "Data source."
          }
         },
         "required": [
          "source"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "find_combos",
    "summary": "Find combos (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "card": {
          "type": "string",
          "description": "One card: its combos."
         },
         "cards": {
          "type": "array",
          "items": {
           "type": "string"
          },
          "maxItems": 250,
          "description": "A list of card names: complete and one-card-away combos."
         },
         "commander": {
          "type": "string",
          "description": "The commander, for combos that need a specific commander."
         },
         "limit": {
          "type": "integer",
          "minimum": 1,
          "maximum": 100,
          "description": "Default 20."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/build": {
   "get": {
    "tags": [
     "Build a deck"
    ],
    "description": "Build a complete, legal deck, the same as the website's deck builder. Commander (default): 100 cards around a commander, using its build plan, synergies, a role balance (ramp, draw, removal, wipes, protection), a mana base sized by Frank Karsten's formulas, and a target power bracket (2 core, 3 upgraded, 4 optimized; Game Changers and infinite combos follow the bracket). Three ways to choose: give a commander (or any card to build around), or criteria (theme, creature type, colors) and the best-fitting commander is picked, or nothing for a random popular commander. Also builds 60-card Standard, Pioneer, Modern, Legacy and Pauper decks around a card. Returns the list in sections with a reason per card, the bracket estimate, combos in the deck, warnings, a paste-ready deck_text and a share_url. A build takes a few seconds.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "format": {
           "type": "string",
           "description": "Format built for."
          },
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander (Commander format)."
          },
          "built_around": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Cards the deck was built around."
          },
          "theme": {
           "type": [
            "string",
            "null"
           ],
           "description": "Theme key, for criteria builds."
          },
          "tribe": {
           "type": [
            "string",
            "null"
           ],
           "description": "Creature type, for criteria builds."
          },
          "total_cards": {
           "type": "integer",
           "description": "Cards in the deck (100 for Commander, commander included)."
          },
          "colors": {
           "type": "string",
           "description": "Color identity of the deck."
          },
          "price_usd": {
           "type": "number",
           "description": "Approximate total price in USD."
          },
          "bracket": {
           "type": [
            "object",
            "null"
           ],
           "description": "Power-bracket estimate.",
           "properties": {
            "bracket": {
             "type": "integer",
             "description": "Estimated power bracket (1-5)."
            },
            "reasons": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Why: Game Changers, combos, tutors, etc."
            }
           },
           "required": [
            "bracket",
            "reasons"
           ]
          },
          "requested_bracket": {
           "type": [
            "integer",
            "null"
           ],
           "description": "Bracket asked for."
          },
          "build_plan": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander's strategy the build followed."
          },
          "land_count_note": {
           "type": "string",
           "description": "How the land count was chosen."
          },
          "warnings": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Problems the builder could not solve (e.g. budget not reachable)."
          },
          "combos": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "Combos complete in the deck."
          },
          "sections": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Section, e.g. \"Ramp\", \"Lands\"."
             },
             "cards": {
              "type": "array",
              "items": {
               "type": "object",
               "properties": {
                "name": {
                 "type": "string",
                 "description": "Card name."
                },
                "qty": {
                 "type": "integer",
                 "description": "Copies."
                },
                "why": {
                 "type": "string",
                 "description": "Why it is in the deck."
                }
               },
               "required": [
                "name",
                "qty",
                "why"
               ]
              }
             }
            },
            "required": [
             "name",
             "cards"
            ]
           },
           "description": "The deck by section."
          },
          "deck_text": {
           "type": "string",
           "description": "The whole list as plain text (\"1 Card Name\" lines with a Commander header), ready to show, paste into deck sites or pass to check_deck."
          },
          "share_url": {
           "type": "string",
           "description": "Opens this deck on deckcosmos.com."
          },
          "buy_url": {
           "type": "string",
           "description": "A TCGplayer cart with the deck's cards (basic lands left out)."
          },
          "note": {
           "type": "string",
           "description": "How to use the result."
          }
         },
         "required": [
          "format",
          "total_cards",
          "sections",
          "deck_text",
          "share_url"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "build_deck_get",
    "summary": "Build a deck",
    "parameters": [
     {
      "name": "commander",
      "in": "query",
      "required": false,
      "description": "The commander (or for 60-card formats, the card to build around).",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "card",
      "in": "query",
      "required": false,
      "description": "Any card to build around; a fitting commander is chosen if it can't be one.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "mode",
      "in": "query",
      "required": false,
      "description": "Usually inferred: card if a commander/card is given, criteria if theme/tribe/colors are, else random.",
      "schema": {
       "type": "string",
       "enum": [
        "card",
        "criteria",
        "random"
       ]
      }
     },
     {
      "name": "theme",
      "in": "query",
      "required": false,
      "description": "Criteria builds: a theme, by key or name. Keys: tokens, sacrifice (aristocrats), counters, lifegain, graveyard, spells (spellslinger), artifacts, enchantments, landfall, blink, voltron (equipment & auras), combat, draw, big (big creatures), flying, trample, deathtouch, strike (first/double strike), haste, evasion (menace & unblockable), lifelink, defenders. See reference what=themes.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "tribe",
      "in": "query",
      "required": false,
      "description": "Criteria builds: a creature type, e.g. \"squirrel\".",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "colors",
      "in": "query",
      "required": false,
      "description": "Criteria builds: color identity letters, e.g. \"BG\". Empty = any.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "format",
      "in": "query",
      "required": false,
      "description": "Default commander.",
      "schema": {
       "type": "string",
       "enum": [
        "commander",
        "standard",
        "pioneer",
        "modern",
        "legacy",
        "pauper"
       ]
      }
     },
     {
      "name": "bracket",
      "in": "query",
      "required": false,
      "description": "Commander power bracket: 2, 3 (default) or 4.",
      "schema": {
       "type": "integer",
       "minimum": 2,
       "maximum": 4
      }
     },
     {
      "name": "max_price_per_card",
      "in": "query",
      "required": false,
      "description": "Skip cards above this USD price.",
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "budget",
      "in": "query",
      "required": false,
      "description": "Total deck budget in USD; expensive cards are swapped for cheaper options.",
      "schema": {
       "type": "number"
      }
     },
     {
      "name": "variation",
      "in": "query",
      "required": false,
      "description": "Add randomness for a different take on the same request. Default false (deterministic).",
      "schema": {
       "type": "boolean"
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Build a deck"
    ],
    "description": "Build a complete, legal deck, the same as the website's deck builder. Commander (default): 100 cards around a commander, using its build plan, synergies, a role balance (ramp, draw, removal, wipes, protection), a mana base sized by Frank Karsten's formulas, and a target power bracket (2 core, 3 upgraded, 4 optimized; Game Changers and infinite combos follow the bracket). Three ways to choose: give a commander (or any card to build around), or criteria (theme, creature type, colors) and the best-fitting commander is picked, or nothing for a random popular commander. Also builds 60-card Standard, Pioneer, Modern, Legacy and Pauper decks around a card. Returns the list in sections with a reason per card, the bracket estimate, combos in the deck, warnings, a paste-ready deck_text and a share_url. A build takes a few seconds.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "format": {
           "type": "string",
           "description": "Format built for."
          },
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander (Commander format)."
          },
          "built_around": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Cards the deck was built around."
          },
          "theme": {
           "type": [
            "string",
            "null"
           ],
           "description": "Theme key, for criteria builds."
          },
          "tribe": {
           "type": [
            "string",
            "null"
           ],
           "description": "Creature type, for criteria builds."
          },
          "total_cards": {
           "type": "integer",
           "description": "Cards in the deck (100 for Commander, commander included)."
          },
          "colors": {
           "type": "string",
           "description": "Color identity of the deck."
          },
          "price_usd": {
           "type": "number",
           "description": "Approximate total price in USD."
          },
          "bracket": {
           "type": [
            "object",
            "null"
           ],
           "description": "Power-bracket estimate.",
           "properties": {
            "bracket": {
             "type": "integer",
             "description": "Estimated power bracket (1-5)."
            },
            "reasons": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Why: Game Changers, combos, tutors, etc."
            }
           },
           "required": [
            "bracket",
            "reasons"
           ]
          },
          "requested_bracket": {
           "type": [
            "integer",
            "null"
           ],
           "description": "Bracket asked for."
          },
          "build_plan": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander's strategy the build followed."
          },
          "land_count_note": {
           "type": "string",
           "description": "How the land count was chosen."
          },
          "warnings": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Problems the builder could not solve (e.g. budget not reachable)."
          },
          "combos": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "Combos complete in the deck."
          },
          "sections": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Section, e.g. \"Ramp\", \"Lands\"."
             },
             "cards": {
              "type": "array",
              "items": {
               "type": "object",
               "properties": {
                "name": {
                 "type": "string",
                 "description": "Card name."
                },
                "qty": {
                 "type": "integer",
                 "description": "Copies."
                },
                "why": {
                 "type": "string",
                 "description": "Why it is in the deck."
                }
               },
               "required": [
                "name",
                "qty",
                "why"
               ]
              }
             }
            },
            "required": [
             "name",
             "cards"
            ]
           },
           "description": "The deck by section."
          },
          "deck_text": {
           "type": "string",
           "description": "The whole list as plain text (\"1 Card Name\" lines with a Commander header), ready to show, paste into deck sites or pass to check_deck."
          },
          "share_url": {
           "type": "string",
           "description": "Opens this deck on deckcosmos.com."
          },
          "buy_url": {
           "type": "string",
           "description": "A TCGplayer cart with the deck's cards (basic lands left out)."
          },
          "note": {
           "type": "string",
           "description": "How to use the result."
          }
         },
         "required": [
          "format",
          "total_cards",
          "sections",
          "deck_text",
          "share_url"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "build_deck",
    "summary": "Build a deck (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "commander": {
          "type": "string",
          "description": "The commander (or for 60-card formats, the card to build around)."
         },
         "card": {
          "type": "string",
          "description": "Any card to build around; a fitting commander is chosen if it can't be one."
         },
         "mode": {
          "type": "string",
          "enum": [
           "card",
           "criteria",
           "random"
          ],
          "description": "Usually inferred: card if a commander/card is given, criteria if theme/tribe/colors are, else random."
         },
         "theme": {
          "type": "string",
          "description": "Criteria builds: a theme, by key or name. Keys: tokens, sacrifice (aristocrats), counters, lifegain, graveyard, spells (spellslinger), artifacts, enchantments, landfall, blink, voltron (equipment & auras), combat, draw, big (big creatures), flying, trample, deathtouch, strike (first/double strike), haste, evasion (menace & unblockable), lifelink, defenders. See reference what=themes."
         },
         "tribe": {
          "type": "string",
          "description": "Criteria builds: a creature type, e.g. \"squirrel\"."
         },
         "colors": {
          "type": "string",
          "description": "Criteria builds: color identity letters, e.g. \"BG\". Empty = any."
         },
         "format": {
          "type": "string",
          "enum": [
           "commander",
           "standard",
           "pioneer",
           "modern",
           "legacy",
           "pauper"
          ],
          "description": "Default commander."
         },
         "bracket": {
          "type": "integer",
          "minimum": 2,
          "maximum": 4,
          "description": "Commander power bracket: 2, 3 (default) or 4."
         },
         "max_price_per_card": {
          "type": "number",
          "description": "Skip cards above this USD price."
         },
         "budget": {
          "type": "number",
          "description": "Total deck budget in USD; expensive cards are swapped for cheaper options."
         },
         "variation": {
          "type": "boolean",
          "description": "Add randomness for a different take on the same request. Default false (deterministic)."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/check": {
   "get": {
    "tags": [
     "Check a deck"
    ],
    "description": "Analyze an existing deck, the same as the website's \"Check a deck\": legality (size, singleton, color identity), counts of ramp, card draw, removal, board wipes and protection against typical ranges, color sources per color vs. what the most demanding card needs, mana curve, bracket estimate with reasons (Game Changers, combos), complete and one-card-away combos, the commander's build-plan key cards it has and lacks, the cards least connected to the deck (cut candidates) and upgrade ideas. Takes a few seconds.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander, as detected or given."
          },
          "total_cards": {
           "type": "integer",
           "description": "Cards in the deck."
          },
          "average_mana_value": {
           "type": "number",
           "description": "Average mana value of nonland cards."
          },
          "unrecognized": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Lines that matched no card."
          },
          "legality_problems": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Size, singleton, color identity and legality problems."
          },
          "role_counts": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "role": {
              "type": "string",
              "description": "Ramp, card draw, removal, board wipes, protection, lands..."
             },
             "count": {
              "type": "integer",
              "description": "How many the deck has."
             },
             "ok": {
              "type": "boolean",
              "description": "Within the typical range."
             },
             "status": {
              "type": "string",
              "description": "low, ok, high, or info (creatures: no fixed range)."
             },
             "typical": {
              "type": [
               "string",
               "null"
              ],
              "description": "Typical range, e.g. \"10-12\"."
             }
            },
            "required": [
             "role",
             "count",
             "ok",
             "status",
             "typical"
            ]
           },
           "description": "Role balance against typical ranges."
          },
          "color_sources": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "color": {
              "type": "string",
              "description": "Color letter."
             },
             "sources": {
              "type": "integer",
              "description": "Lands and rocks making it."
             },
             "wanted": {
              "type": [
               "integer",
               "null"
              ],
              "description": "Sources recommended (Frank Karsten) for the most demanding card."
             },
             "wanted_for": {
              "type": [
               "string",
               "null"
              ],
              "description": "That card."
             },
             "ok": {
              "type": "boolean",
              "description": "Enough sources."
             }
            },
            "required": [
             "color",
             "sources",
             "wanted",
             "wanted_for",
             "ok"
            ]
           },
           "description": "Mana sources per color."
          },
          "mana_curve": {
           "type": "object",
           "description": "Nonland cards by mana value: keys \"0\" to \"6\" and \"7+\".",
           "additionalProperties": {
            "type": "integer"
           }
          },
          "bracket": {
           "type": [
            "object",
            "null"
           ],
           "description": "Power-bracket estimate.",
           "properties": {
            "bracket": {
             "type": "integer",
             "description": "Estimated power bracket (1-5)."
            },
            "reasons": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Why: Game Changers, combos, tutors, etc."
            }
           },
           "required": [
            "bracket",
            "reasons"
           ]
          },
          "combos": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "Combos complete in the deck."
          },
          "one_card_from_combo": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "add": {
              "type": "string",
              "description": "The card that would complete it."
             },
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "add",
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "Combos one added card would complete."
          },
          "build_plan": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander's build plan."
          },
          "plan_key_cards": {
           "type": [
            "object",
            "null"
           ],
           "description": "The build plan's key cards.",
           "properties": {
            "have": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Key cards in the deck."
            },
            "missing": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Key cards not in it."
            },
            "total": {
             "type": "integer",
             "description": "Key cards in the plan."
            }
           },
           "required": [
            "have",
            "missing",
            "total"
           ]
          },
          "consider_cutting": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Cards least connected to the rest of the deck."
          },
          "upgrade_ideas": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card to consider adding."
             },
             "why": {
              "type": "string",
              "description": "Why."
             }
            },
            "required": [
             "name",
             "why"
            ]
           },
           "description": "Additions that fit the deck and bracket."
          },
          "share_url": {
           "type": "string",
           "description": "Opens the deck on deckcosmos.com."
          },
          "buy_url": {
           "type": "string",
           "description": "A TCGplayer cart with the deck's cards (basic lands left out)."
          }
         },
         "required": [
          "total_cards",
          "legality_problems",
          "role_counts",
          "share_url"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "check_deck_get",
    "summary": "Check a deck",
    "parameters": [
     {
      "name": "decklist",
      "in": "query",
      "required": false,
      "description": "The deck as text: one \"1 Card Name\" per line. Moxfield, Archidekt and Arena exports, .dek XML and CSV work; a \"Commander\" header line (or *CMDR*) marks the commander.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "cards",
      "in": "query",
      "required": false,
      "description": "Alternative to decklist: [{\"name\": \"Sol Ring\", \"qty\": 1}, ...] or plain names. Repeat the parameter or separate values with |.",
      "schema": {
       "type": "array",
       "items": {
        "type": "string"
       }
      },
      "style": "form",
      "explode": true
     },
     {
      "name": "commander",
      "in": "query",
      "required": false,
      "description": "Commander name, if the list does not mark it. Otherwise it is detected like on the website.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "bracket",
      "in": "query",
      "required": false,
      "description": "Bracket to aim upgrade ideas at. Default: the deck's estimated bracket.",
      "schema": {
       "type": "integer",
       "minimum": 2,
       "maximum": 4
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Check a deck"
    ],
    "description": "Analyze an existing deck, the same as the website's \"Check a deck\": legality (size, singleton, color identity), counts of ramp, card draw, removal, board wipes and protection against typical ranges, color sources per color vs. what the most demanding card needs, mana curve, bracket estimate with reasons (Game Changers, combos), complete and one-card-away combos, the commander's build-plan key cards it has and lacks, the cards least connected to the deck (cut candidates) and upgrade ideas. Takes a few seconds.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander, as detected or given."
          },
          "total_cards": {
           "type": "integer",
           "description": "Cards in the deck."
          },
          "average_mana_value": {
           "type": "number",
           "description": "Average mana value of nonland cards."
          },
          "unrecognized": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Lines that matched no card."
          },
          "legality_problems": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Size, singleton, color identity and legality problems."
          },
          "role_counts": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "role": {
              "type": "string",
              "description": "Ramp, card draw, removal, board wipes, protection, lands..."
             },
             "count": {
              "type": "integer",
              "description": "How many the deck has."
             },
             "ok": {
              "type": "boolean",
              "description": "Within the typical range."
             },
             "status": {
              "type": "string",
              "description": "low, ok, high, or info (creatures: no fixed range)."
             },
             "typical": {
              "type": [
               "string",
               "null"
              ],
              "description": "Typical range, e.g. \"10-12\"."
             }
            },
            "required": [
             "role",
             "count",
             "ok",
             "status",
             "typical"
            ]
           },
           "description": "Role balance against typical ranges."
          },
          "color_sources": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "color": {
              "type": "string",
              "description": "Color letter."
             },
             "sources": {
              "type": "integer",
              "description": "Lands and rocks making it."
             },
             "wanted": {
              "type": [
               "integer",
               "null"
              ],
              "description": "Sources recommended (Frank Karsten) for the most demanding card."
             },
             "wanted_for": {
              "type": [
               "string",
               "null"
              ],
              "description": "That card."
             },
             "ok": {
              "type": "boolean",
              "description": "Enough sources."
             }
            },
            "required": [
             "color",
             "sources",
             "wanted",
             "wanted_for",
             "ok"
            ]
           },
           "description": "Mana sources per color."
          },
          "mana_curve": {
           "type": "object",
           "description": "Nonland cards by mana value: keys \"0\" to \"6\" and \"7+\".",
           "additionalProperties": {
            "type": "integer"
           }
          },
          "bracket": {
           "type": [
            "object",
            "null"
           ],
           "description": "Power-bracket estimate.",
           "properties": {
            "bracket": {
             "type": "integer",
             "description": "Estimated power bracket (1-5)."
            },
            "reasons": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Why: Game Changers, combos, tutors, etc."
            }
           },
           "required": [
            "bracket",
            "reasons"
           ]
          },
          "combos": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "Combos complete in the deck."
          },
          "one_card_from_combo": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "add": {
              "type": "string",
              "description": "The card that would complete it."
             },
             "cards": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The cards in the combo."
             },
             "results": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "What it does, e.g. \"Infinite mana\"."
             },
             "extra_requirements": {
              "type": "integer",
              "description": "How many other requirements it has beyond the cards (0 = just the cards)."
             },
             "commander_must_be": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Cards among these that must be the commander, if any."
             },
             "popularity": {
              "type": "integer",
              "description": "How many decks on Commander Spellbook's source sites play it."
             },
             "bracket_tag": {
              "type": [
               "string",
               "null"
              ],
              "description": "Commander Spellbook's bracket tag for the combo."
             },
             "url": {
              "type": "string",
              "description": "Commander Spellbook page with the steps."
             }
            },
            "required": [
             "add",
             "cards",
             "results",
             "extra_requirements",
             "commander_must_be",
             "popularity",
             "bracket_tag",
             "url"
            ]
           },
           "description": "Combos one added card would complete."
          },
          "build_plan": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander's build plan."
          },
          "plan_key_cards": {
           "type": [
            "object",
            "null"
           ],
           "description": "The build plan's key cards.",
           "properties": {
            "have": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Key cards in the deck."
            },
            "missing": {
             "type": "array",
             "items": {
              "type": "string"
             },
             "description": "Key cards not in it."
            },
            "total": {
             "type": "integer",
             "description": "Key cards in the plan."
            }
           },
           "required": [
            "have",
            "missing",
            "total"
           ]
          },
          "consider_cutting": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Cards least connected to the rest of the deck."
          },
          "upgrade_ideas": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card to consider adding."
             },
             "why": {
              "type": "string",
              "description": "Why."
             }
            },
            "required": [
             "name",
             "why"
            ]
           },
           "description": "Additions that fit the deck and bracket."
          },
          "share_url": {
           "type": "string",
           "description": "Opens the deck on deckcosmos.com."
          },
          "buy_url": {
           "type": "string",
           "description": "A TCGplayer cart with the deck's cards (basic lands left out)."
          }
         },
         "required": [
          "total_cards",
          "legality_problems",
          "role_counts",
          "share_url"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "check_deck",
    "summary": "Check a deck (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "decklist": {
          "type": "string",
          "description": "The deck as text: one \"1 Card Name\" per line. Moxfield, Archidekt and Arena exports, .dek XML and CSV work; a \"Commander\" header line (or *CMDR*) marks the commander.",
          "maxLength": 60000
         },
         "cards": {
          "type": "array",
          "description": "Alternative to decklist: [{\"name\": \"Sol Ring\", \"qty\": 1}, ...] or plain names.",
          "maxItems": 250,
          "items": {
           "anyOf": [
            {
             "type": "string"
            },
            {
             "type": "object",
             "properties": {
              "name": {
               "type": "string"
              },
              "qty": {
               "type": "integer",
               "minimum": 1
              }
             },
             "required": [
              "name"
             ]
            }
           ]
          }
         },
         "commander": {
          "type": "string",
          "description": "Commander name, if the list does not mark it. Otherwise it is detected like on the website."
         },
         "bracket": {
          "type": "integer",
          "minimum": 2,
          "maximum": 4,
          "description": "Bracket to aim upgrade ideas at. Default: the deck's estimated bracket."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/simulate": {
   "get": {
    "tags": [
     "Simulate a deck's mana"
    ],
    "description": "Monte Carlo consistency test, the same as the website's playtest simulator: plays the deck alone thousands of times and reports mulligan, mana screw and flood rates, lands and mana by turn, when the commander gets cast, how often a build-plan key card is drawn by turn 4, and how much mana gets used.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "cards": {
           "type": "integer",
           "description": "Cards in the deck."
          },
          "games": {
           "type": "integer",
           "description": "Games simulated."
          },
          "on_the_play": {
           "type": "boolean",
           "description": "On the play (else on the draw)."
          },
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander."
          },
          "unrecognized": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Lines that matched no card."
          },
          "mulligan_percent": {
           "type": "number",
           "description": "Opening hands mulliganed (too few or too many lands), %."
          },
          "mana_screw_percent": {
           "type": "number",
           "description": "Games stuck on lands, %."
          },
          "flood_percent": {
           "type": "number",
           "description": "Games drawing too many lands, %."
          },
          "key_card_by_turn_4_percent": {
           "type": [
            "number",
            "null"
           ],
           "description": "Games with a build-plan key card in hand by turn 4, %."
          },
          "mana_used_percent": {
           "type": "number",
           "description": "Share of available mana spent, %."
          },
          "by_turn": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "turn": {
              "type": "integer",
              "description": "Turn."
             },
             "lands": {
              "type": "number",
              "description": "Average lands in play."
             },
             "mana": {
              "type": "number",
              "description": "Average mana available."
             },
             "commander_cast_percent": {
              "type": [
               "number",
               "null"
              ],
              "description": "Games with the commander cast by this turn, %."
             }
            },
            "required": [
             "turn",
             "lands",
             "mana",
             "commander_cast_percent"
            ]
           },
           "description": "Averages by turn."
          },
          "method": {
           "type": "string",
           "description": "How the simulation plays."
          }
         },
         "required": [
          "games",
          "by_turn"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "simulate_deck_get",
    "summary": "Simulate a deck's mana",
    "parameters": [
     {
      "name": "decklist",
      "in": "query",
      "required": false,
      "description": "The deck as text: one \"1 Card Name\" per line. Moxfield, Archidekt and Arena exports, .dek XML and CSV work; a \"Commander\" header line (or *CMDR*) marks the commander.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "cards",
      "in": "query",
      "required": false,
      "description": "Alternative to decklist: [{\"name\": \"Sol Ring\", \"qty\": 1}, ...] or plain names. Repeat the parameter or separate values with |.",
      "schema": {
       "type": "array",
       "items": {
        "type": "string"
       }
      },
      "style": "form",
      "explode": true
     },
     {
      "name": "commander",
      "in": "query",
      "required": false,
      "description": "Commander name, if the list does not mark it. Otherwise it is detected like on the website.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "games",
      "in": "query",
      "required": false,
      "description": "Default 3000.",
      "schema": {
       "type": "integer",
       "minimum": 100,
       "maximum": 10000
      }
     },
     {
      "name": "on_play",
      "in": "query",
      "required": false,
      "description": "On the play (default) or the draw.",
      "schema": {
       "type": "boolean"
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Simulate a deck's mana"
    ],
    "description": "Monte Carlo consistency test, the same as the website's playtest simulator: plays the deck alone thousands of times and reports mulligan, mana screw and flood rates, lands and mana by turn, when the commander gets cast, how often a build-plan key card is drawn by turn 4, and how much mana gets used.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "cards": {
           "type": "integer",
           "description": "Cards in the deck."
          },
          "games": {
           "type": "integer",
           "description": "Games simulated."
          },
          "on_the_play": {
           "type": "boolean",
           "description": "On the play (else on the draw)."
          },
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander."
          },
          "unrecognized": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "Lines that matched no card."
          },
          "mulligan_percent": {
           "type": "number",
           "description": "Opening hands mulliganed (too few or too many lands), %."
          },
          "mana_screw_percent": {
           "type": "number",
           "description": "Games stuck on lands, %."
          },
          "flood_percent": {
           "type": "number",
           "description": "Games drawing too many lands, %."
          },
          "key_card_by_turn_4_percent": {
           "type": [
            "number",
            "null"
           ],
           "description": "Games with a build-plan key card in hand by turn 4, %."
          },
          "mana_used_percent": {
           "type": "number",
           "description": "Share of available mana spent, %."
          },
          "by_turn": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "turn": {
              "type": "integer",
              "description": "Turn."
             },
             "lands": {
              "type": "number",
              "description": "Average lands in play."
             },
             "mana": {
              "type": "number",
              "description": "Average mana available."
             },
             "commander_cast_percent": {
              "type": [
               "number",
               "null"
              ],
              "description": "Games with the commander cast by this turn, %."
             }
            },
            "required": [
             "turn",
             "lands",
             "mana",
             "commander_cast_percent"
            ]
           },
           "description": "Averages by turn."
          },
          "method": {
           "type": "string",
           "description": "How the simulation plays."
          }
         },
         "required": [
          "games",
          "by_turn"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "simulate_deck",
    "summary": "Simulate a deck's mana (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "decklist": {
          "type": "string",
          "description": "The deck as text: one \"1 Card Name\" per line. Moxfield, Archidekt and Arena exports, .dek XML and CSV work; a \"Commander\" header line (or *CMDR*) marks the commander.",
          "maxLength": 60000
         },
         "cards": {
          "type": "array",
          "description": "Alternative to decklist: [{\"name\": \"Sol Ring\", \"qty\": 1}, ...] or plain names.",
          "maxItems": 250,
          "items": {
           "anyOf": [
            {
             "type": "string"
            },
            {
             "type": "object",
             "properties": {
              "name": {
               "type": "string"
              },
              "qty": {
               "type": "integer",
               "minimum": 1
              }
             },
             "required": [
              "name"
             ]
            }
           ]
          }
         },
         "commander": {
          "type": "string",
          "description": "Commander name, if the list does not mark it. Otherwise it is detected like on the website."
         },
         "games": {
          "type": "integer",
          "minimum": 100,
          "maximum": 10000,
          "description": "Default 3000."
         },
         "on_play": {
          "type": "boolean",
          "description": "On the play (default) or the draw."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/odds": {
   "get": {
    "tags": [
     "Draw odds"
    ],
    "description": "Exact (hypergeometric) chance of drawing at least N of something by a given turn, with the table for turns 1-10, the same as the website's odds calculator. Target: \"lands\", \"role:<role key>\" (e.g. role:land_ramp) or a card name.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "target": {
           "type": "string",
           "description": "What was counted."
          },
          "copies_in_library": {
           "type": "integer",
           "description": "Copies of the target in the library."
          },
          "library_size": {
           "type": "integer",
           "description": "Library size."
          },
          "at_least": {
           "type": "integer",
           "description": "How many needed."
          },
          "on_the_play": {
           "type": "boolean",
           "description": "On the play (no draw on turn 1)."
          },
          "turn": {
           "type": "integer",
           "description": "Turn asked about."
          },
          "percent": {
           "type": "number",
           "description": "Chance by that turn, %."
          },
          "by_turn": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "turn": {
              "type": "integer",
              "description": "Turn."
             },
             "cards_seen": {
              "type": "integer",
              "description": "Cards seen by then."
             },
             "percent": {
              "type": "number",
              "description": "Chance, %."
             }
            },
            "required": [
             "turn",
             "cards_seen",
             "percent"
            ]
           },
           "description": "Turns 1-10."
          },
          "method": {
           "type": "string",
           "description": "How it was calculated."
          }
         },
         "required": [
          "percent",
          "by_turn"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "draw_odds_get",
    "summary": "Draw odds",
    "parameters": [
     {
      "name": "decklist",
      "in": "query",
      "required": false,
      "description": "The deck as text: one \"1 Card Name\" per line. Moxfield, Archidekt and Arena exports, .dek XML and CSV work; a \"Commander\" header line (or *CMDR*) marks the commander.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "cards",
      "in": "query",
      "required": false,
      "description": "Alternative to decklist: [{\"name\": \"Sol Ring\", \"qty\": 1}, ...] or plain names. Repeat the parameter or separate values with |.",
      "schema": {
       "type": "array",
       "items": {
        "type": "string"
       }
      },
      "style": "form",
      "explode": true
     },
     {
      "name": "commander",
      "in": "query",
      "required": false,
      "description": "Commander name, if the list does not mark it. Otherwise it is detected like on the website.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "target",
      "in": "query",
      "required": false,
      "description": "\"lands\", \"role:<key>\" or a card name. Default lands.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "at_least",
      "in": "query",
      "required": false,
      "description": "Default 1.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 20
      }
     },
     {
      "name": "turn",
      "in": "query",
      "required": false,
      "description": "Default 3.",
      "schema": {
       "type": "integer",
       "minimum": 1,
       "maximum": 20
      }
     },
     {
      "name": "on_play",
      "in": "query",
      "required": false,
      "description": "Default true.",
      "schema": {
       "type": "boolean"
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Draw odds"
    ],
    "description": "Exact (hypergeometric) chance of drawing at least N of something by a given turn, with the table for turns 1-10, the same as the website's odds calculator. Target: \"lands\", \"role:<role key>\" (e.g. role:land_ramp) or a card name.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "target": {
           "type": "string",
           "description": "What was counted."
          },
          "copies_in_library": {
           "type": "integer",
           "description": "Copies of the target in the library."
          },
          "library_size": {
           "type": "integer",
           "description": "Library size."
          },
          "at_least": {
           "type": "integer",
           "description": "How many needed."
          },
          "on_the_play": {
           "type": "boolean",
           "description": "On the play (no draw on turn 1)."
          },
          "turn": {
           "type": "integer",
           "description": "Turn asked about."
          },
          "percent": {
           "type": "number",
           "description": "Chance by that turn, %."
          },
          "by_turn": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "turn": {
              "type": "integer",
              "description": "Turn."
             },
             "cards_seen": {
              "type": "integer",
              "description": "Cards seen by then."
             },
             "percent": {
              "type": "number",
              "description": "Chance, %."
             }
            },
            "required": [
             "turn",
             "cards_seen",
             "percent"
            ]
           },
           "description": "Turns 1-10."
          },
          "method": {
           "type": "string",
           "description": "How it was calculated."
          }
         },
         "required": [
          "percent",
          "by_turn"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "draw_odds",
    "summary": "Draw odds (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "decklist": {
          "type": "string",
          "description": "The deck as text: one \"1 Card Name\" per line. Moxfield, Archidekt and Arena exports, .dek XML and CSV work; a \"Commander\" header line (or *CMDR*) marks the commander.",
          "maxLength": 60000
         },
         "cards": {
          "type": "array",
          "description": "Alternative to decklist: [{\"name\": \"Sol Ring\", \"qty\": 1}, ...] or plain names.",
          "maxItems": 250,
          "items": {
           "anyOf": [
            {
             "type": "string"
            },
            {
             "type": "object",
             "properties": {
              "name": {
               "type": "string"
              },
              "qty": {
               "type": "integer",
               "minimum": 1
              }
             },
             "required": [
              "name"
             ]
            }
           ]
          }
         },
         "commander": {
          "type": "string",
          "description": "Commander name, if the list does not mark it. Otherwise it is detected like on the website."
         },
         "target": {
          "type": "string",
          "description": "\"lands\", \"role:<key>\" or a card name. Default lands."
         },
         "at_least": {
          "type": "integer",
          "minimum": 1,
          "maximum": 20,
          "description": "Default 1."
         },
         "turn": {
          "type": "integer",
          "minimum": 1,
          "maximum": 20,
          "description": "Default 3."
         },
         "on_play": {
          "type": "boolean",
          "description": "Default true."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/hand": {
   "get": {
    "tags": [
     "Sample opening hand"
    ],
    "description": "Shuffle the deck and draw a random 7-card opening hand (the commander stays in the command zone), plus optionally the next draws.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander (in the command zone, not the hand)."
          },
          "hand": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card name."
             },
             "mana_cost": {
              "type": "string",
              "description": "Mana cost."
             },
             "type": {
              "type": "string",
              "description": "Type line."
             }
            },
            "required": [
             "name",
             "mana_cost",
             "type"
            ]
           },
           "description": "Seven cards."
          },
          "lands_in_hand": {
           "type": "integer",
           "description": "Lands in the hand."
          },
          "next_draws": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "The next draws, if asked."
          }
         },
         "required": [
          "hand"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "sample_hand_get",
    "summary": "Sample opening hand",
    "parameters": [
     {
      "name": "decklist",
      "in": "query",
      "required": false,
      "description": "The deck as text: one \"1 Card Name\" per line. Moxfield, Archidekt and Arena exports, .dek XML and CSV work; a \"Commander\" header line (or *CMDR*) marks the commander.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "cards",
      "in": "query",
      "required": false,
      "description": "Alternative to decklist: [{\"name\": \"Sol Ring\", \"qty\": 1}, ...] or plain names. Repeat the parameter or separate values with |.",
      "schema": {
       "type": "array",
       "items": {
        "type": "string"
       }
      },
      "style": "form",
      "explode": true
     },
     {
      "name": "commander",
      "in": "query",
      "required": false,
      "description": "Commander name, if the list does not mark it. Otherwise it is detected like on the website.",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "draws",
      "in": "query",
      "required": false,
      "description": "Also show the next N draws. Default 0.",
      "schema": {
       "type": "integer",
       "minimum": 0,
       "maximum": 10
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Sample opening hand"
    ],
    "description": "Shuffle the deck and draw a random 7-card opening hand (the commander stays in the command zone), plus optionally the next draws.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "commander": {
           "type": [
            "string",
            "null"
           ],
           "description": "The commander (in the command zone, not the hand)."
          },
          "hand": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Card name."
             },
             "mana_cost": {
              "type": "string",
              "description": "Mana cost."
             },
             "type": {
              "type": "string",
              "description": "Type line."
             }
            },
            "required": [
             "name",
             "mana_cost",
             "type"
            ]
           },
           "description": "Seven cards."
          },
          "lands_in_hand": {
           "type": "integer",
           "description": "Lands in the hand."
          },
          "next_draws": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "The next draws, if asked."
          }
         },
         "required": [
          "hand"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "sample_hand",
    "summary": "Sample opening hand (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "decklist": {
          "type": "string",
          "description": "The deck as text: one \"1 Card Name\" per line. Moxfield, Archidekt and Arena exports, .dek XML and CSV work; a \"Commander\" header line (or *CMDR*) marks the commander.",
          "maxLength": 60000
         },
         "cards": {
          "type": "array",
          "description": "Alternative to decklist: [{\"name\": \"Sol Ring\", \"qty\": 1}, ...] or plain names.",
          "maxItems": 250,
          "items": {
           "anyOf": [
            {
             "type": "string"
            },
            {
             "type": "object",
             "properties": {
              "name": {
               "type": "string"
              },
              "qty": {
               "type": "integer",
               "minimum": 1
              }
             },
             "required": [
              "name"
             ]
            }
           ]
          }
         },
         "commander": {
          "type": "string",
          "description": "Commander name, if the list does not mark it. Otherwise it is detected like on the website."
         },
         "draws": {
          "type": "integer",
          "minimum": 0,
          "maximum": 10,
          "description": "Also show the next N draws. Default 0."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/rules": {
   "get": {
    "tags": [
     "Comprehensive Rules lookup"
    ],
    "description": "Look up the official Comprehensive Rules: by number (\"702.19\" trample, with its subrules and examples; \"702\" lists the keyword abilities) or by term (\"deathtouch\", \"dies\", \"state-based actions\"), including the glossary.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "effective": {
           "type": "string",
           "description": "Date of the Comprehensive Rules used."
          },
          "source": {
           "type": "string",
           "description": "Where the rules come from."
          },
          "rule": {
           "type": "string",
           "description": "With \"rule\": the rule number."
          },
          "text": {
           "type": "string",
           "description": "With \"rule\": its text."
          },
          "examples": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "With \"rule\": its examples."
          },
          "subrules": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "rule": {
              "type": "string",
              "description": "Rule number."
             },
             "text": {
              "type": "string",
              "description": "Rule text."
             },
             "examples": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The rule's examples."
             }
            },
            "required": [
             "rule",
             "text",
             "examples"
            ]
           },
           "description": "With \"rule\": its subrules."
          },
          "children": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "rule": {
              "type": "string",
              "description": "Rule number."
             },
             "title": {
              "type": "string",
              "description": "Title or start of the text."
             }
            },
            "required": [
             "rule",
             "title"
            ]
           },
           "description": "With a section number (e.g. \"702\"): the rules in it."
          },
          "query": {
           "type": "string",
           "description": "With \"query\": the term."
          },
          "results": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "term": {
              "type": "string",
              "description": "Matched term."
             },
             "glossary": {
              "type": "string",
              "description": "Glossary entry name, if from the glossary."
             },
             "rule": {
              "type": "string",
              "description": "Rule number, if a rule."
             },
             "text": {
              "type": "string",
              "description": "Text."
             },
             "subrules": {
              "type": "array",
              "items": {
               "type": "object",
               "properties": {
                "rule": {
                 "type": "string",
                 "description": "Rule number."
                },
                "text": {
                 "type": "string",
                 "description": "Rule text."
                },
                "examples": {
                 "type": "array",
                 "items": {
                  "type": "string"
                 },
                 "description": "The rule's examples."
                }
               },
               "required": [
                "rule",
                "text",
                "examples"
               ]
              },
              "description": "Its subrules."
             },
             "examples": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Its examples."
             }
            },
            "required": [
             "text"
            ]
           },
           "description": "With \"query\": matching glossary entries and rules."
          }
         },
         "required": [
          "effective",
          "source"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "lookup_rules_get",
    "summary": "Comprehensive Rules lookup",
    "parameters": [
     {
      "name": "rule",
      "in": "query",
      "required": false,
      "description": "A rule number, e.g. \"702.19\", \"702.19b\", \"702\", \"7\".",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "query",
      "in": "query",
      "required": false,
      "description": "A term or keyword, e.g. \"trample\", \"commander tax\", \"dies\".",
      "schema": {
       "type": "string"
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Comprehensive Rules lookup"
    ],
    "description": "Look up the official Comprehensive Rules: by number (\"702.19\" trample, with its subrules and examples; \"702\" lists the keyword abilities) or by term (\"deathtouch\", \"dies\", \"state-based actions\"), including the glossary.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "effective": {
           "type": "string",
           "description": "Date of the Comprehensive Rules used."
          },
          "source": {
           "type": "string",
           "description": "Where the rules come from."
          },
          "rule": {
           "type": "string",
           "description": "With \"rule\": the rule number."
          },
          "text": {
           "type": "string",
           "description": "With \"rule\": its text."
          },
          "examples": {
           "type": "array",
           "items": {
            "type": "string"
           },
           "description": "With \"rule\": its examples."
          },
          "subrules": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "rule": {
              "type": "string",
              "description": "Rule number."
             },
             "text": {
              "type": "string",
              "description": "Rule text."
             },
             "examples": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "The rule's examples."
             }
            },
            "required": [
             "rule",
             "text",
             "examples"
            ]
           },
           "description": "With \"rule\": its subrules."
          },
          "children": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "rule": {
              "type": "string",
              "description": "Rule number."
             },
             "title": {
              "type": "string",
              "description": "Title or start of the text."
             }
            },
            "required": [
             "rule",
             "title"
            ]
           },
           "description": "With a section number (e.g. \"702\"): the rules in it."
          },
          "query": {
           "type": "string",
           "description": "With \"query\": the term."
          },
          "results": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "term": {
              "type": "string",
              "description": "Matched term."
             },
             "glossary": {
              "type": "string",
              "description": "Glossary entry name, if from the glossary."
             },
             "rule": {
              "type": "string",
              "description": "Rule number, if a rule."
             },
             "text": {
              "type": "string",
              "description": "Text."
             },
             "subrules": {
              "type": "array",
              "items": {
               "type": "object",
               "properties": {
                "rule": {
                 "type": "string",
                 "description": "Rule number."
                },
                "text": {
                 "type": "string",
                 "description": "Rule text."
                },
                "examples": {
                 "type": "array",
                 "items": {
                  "type": "string"
                 },
                 "description": "The rule's examples."
                }
               },
               "required": [
                "rule",
                "text",
                "examples"
               ]
              },
              "description": "Its subrules."
             },
             "examples": {
              "type": "array",
              "items": {
               "type": "string"
              },
              "description": "Its examples."
             }
            },
            "required": [
             "text"
            ]
           },
           "description": "With \"query\": matching glossary entries and rules."
          }
         },
         "required": [
          "effective",
          "source"
         ]
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "lookup_rules",
    "summary": "Comprehensive Rules lookup (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "rule": {
          "type": "string",
          "description": "A rule number, e.g. \"702.19\", \"702.19b\", \"702\", \"7\"."
         },
         "query": {
          "type": "string",
          "description": "A term or keyword, e.g. \"trample\", \"commander tax\", \"dies\"."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/reference": {
   "get": {
    "tags": [
     "Reference lists"
    ],
    "description": "The keys other tools accept: deck-builder themes, formats, card roles (for search_cards and draw_odds), synergy categories (for get_synergies) and power brackets.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "themes": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "key": {
              "type": "string",
              "description": "Key for build_deck theme."
             },
             "label": {
              "type": "string",
              "description": "Name."
             },
             "group": {
              "type": "string",
              "description": "Group."
             }
            },
            "required": [
             "key",
             "label",
             "group"
            ]
           },
           "description": "Deck-builder themes."
          },
          "formats": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Key."
             },
             "label": {
              "type": "string",
              "description": "Name."
             },
             "deck_builder": {
              "type": "boolean",
              "description": "build_deck supports it."
             }
            },
            "required": [
             "name",
             "label",
             "deck_builder"
            ]
           },
           "description": "Formats."
          },
          "roles": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "key": {
              "type": "string",
              "description": "Role key."
             },
             "label": {
              "type": "string",
              "description": "Name."
             },
             "category": {
              "type": "string",
              "description": "Group."
             },
             "searchable": {
              "type": "boolean",
              "description": "Usable as a search_cards role filter."
             }
            },
            "required": [
             "key",
             "label",
             "category",
             "searchable"
            ]
           },
           "description": "Card roles."
          },
          "categories": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "key": {
              "type": "string",
              "description": "Category key."
             },
             "label": {
              "type": "string",
              "description": "Name."
             }
            },
            "required": [
             "key",
             "label"
            ]
           },
           "description": "Synergy categories (get_synergies categories)."
          },
          "brackets": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "bracket": {
              "type": "integer",
              "description": "Bracket number."
             },
             "label": {
              "type": "string",
              "description": "Name."
             },
             "rules": {
              "type": "string",
              "description": "What it allows."
             }
            },
            "required": [
             "bracket",
             "label",
             "rules"
            ]
           },
           "description": "Commander power brackets."
          }
         },
         "required": []
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "reference_get",
    "summary": "Reference lists",
    "parameters": [
     {
      "name": "what",
      "in": "query",
      "required": false,
      "description": "Omit for all of them.",
      "schema": {
       "type": "string",
       "enum": [
        "themes",
        "formats",
        "roles",
        "categories",
        "brackets"
       ]
      }
     }
    ]
   },
   "post": {
    "tags": [
     "Reference lists"
    ],
    "description": "The keys other tools accept: deck-builder themes, formats, card roles (for search_cards and draw_odds), synergy categories (for get_synergies) and power brackets.",
    "responses": {
     "200": {
      "description": "Result.",
      "content": {
       "application/json": {
        "schema": {
         "type": "object",
         "properties": {
          "themes": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "key": {
              "type": "string",
              "description": "Key for build_deck theme."
             },
             "label": {
              "type": "string",
              "description": "Name."
             },
             "group": {
              "type": "string",
              "description": "Group."
             }
            },
            "required": [
             "key",
             "label",
             "group"
            ]
           },
           "description": "Deck-builder themes."
          },
          "formats": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "name": {
              "type": "string",
              "description": "Key."
             },
             "label": {
              "type": "string",
              "description": "Name."
             },
             "deck_builder": {
              "type": "boolean",
              "description": "build_deck supports it."
             }
            },
            "required": [
             "name",
             "label",
             "deck_builder"
            ]
           },
           "description": "Formats."
          },
          "roles": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "key": {
              "type": "string",
              "description": "Role key."
             },
             "label": {
              "type": "string",
              "description": "Name."
             },
             "category": {
              "type": "string",
              "description": "Group."
             },
             "searchable": {
              "type": "boolean",
              "description": "Usable as a search_cards role filter."
             }
            },
            "required": [
             "key",
             "label",
             "category",
             "searchable"
            ]
           },
           "description": "Card roles."
          },
          "categories": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "key": {
              "type": "string",
              "description": "Category key."
             },
             "label": {
              "type": "string",
              "description": "Name."
             }
            },
            "required": [
             "key",
             "label"
            ]
           },
           "description": "Synergy categories (get_synergies categories)."
          },
          "brackets": {
           "type": "array",
           "items": {
            "type": "object",
            "properties": {
             "bracket": {
              "type": "integer",
              "description": "Bracket number."
             },
             "label": {
              "type": "string",
              "description": "Name."
             },
             "rules": {
              "type": "string",
              "description": "What it allows."
             }
            },
            "required": [
             "bracket",
             "label",
             "rules"
            ]
           },
           "description": "Commander power brackets."
          }
         },
         "required": []
        }
       }
      }
     },
     "400": {
      "description": "Bad input (unknown card, invalid option). The message says what to change; unknown cards come with suggestions.",
      "content": {
       "application/json": {
        "schema": {
         "$ref": "#/components/schemas/Error"
        }
       }
      }
     },
     "429": {
      "description": "Rate limited; see Retry-After."
     },
     "503": {
      "description": "Busy; retry shortly."
     }
    },
    "operationId": "reference",
    "summary": "Reference lists (JSON body)",
    "requestBody": {
     "required": true,
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "what": {
          "type": "string",
          "enum": [
           "themes",
           "formats",
           "roles",
           "categories",
           "brackets"
          ],
          "description": "Omit for all of them."
         }
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/cards/{slug}.json": {
   "get": {
    "tags": [
     "Static files"
    ],
    "operationId": "static_card",
    "summary": "Card file (static)",
    "description": "Pre-built JSON for a card with a page on deckcosmos.com: everything get_card returns, plus its top 20 synergies and top 10 combos. Rebuilt weekly. Slugs: lowercase name, punctuation removed, spaces as hyphens (see cards.json).",
    "parameters": [
     {
      "name": "slug",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      },
      "example": "krenko-mob-boss"
     }
    ],
    "responses": {
     "200": {
      "description": "Card",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     },
     "404": {
      "description": "No such card page."
     }
    }
   }
  },
  "/api/v1/cards.json": {
   "get": {
    "tags": [
     "Static files"
    ],
    "operationId": "static_card_index",
    "summary": "Index of card files (static)",
    "responses": {
     "200": {
      "description": "Index",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  },
  "/api/v1/commanders.json": {
   "get": {
    "tags": [
     "Static files"
    ],
    "operationId": "static_commanders",
    "summary": "Commanders with build plans (static)",
    "responses": {
     "200": {
      "description": "Commanders",
      "content": {
       "application/json": {
        "schema": {
         "type": "object"
        }
       }
      }
     }
    }
   }
  }
 },
 "components": {
  "schemas": {
   "Error": {
    "type": "object",
    "properties": {
     "error": {
      "type": "string"
     },
     "suggestions": {
      "type": "array",
      "items": {
       "type": "string"
      }
     }
    },
    "required": [
     "error"
    ]
   }
  }
 }
}