在 Scryfall API 调用中选择颜色

问题描述 投票:0回答:1

我正在使用 python 和 PyQt6 开发一个简单的项目,该项目允许用户为 MTG 指挥官选择他们想要的颜色,然后使用 Scryfall API 返回具有该颜色标识的随机指挥官。我已经阅读了 API 和常规 scryfall 的文档,并且已经到了我不明白发生了什么的地步。 我使用 https://api.scryfall.com/cards/random?q=is%3Acommander 作为基本链接并添加额外内容。

起初我以为我可以在所有选定颜色的链中执行 +c%3A{color} ,但这只需要这些颜色位于卡片上,有时它会得到一张带有外部颜色的卡片我指定的那些。然后我用 - 而不是 + 尝试了一系列的操作,但这只是破坏了它。 最终我得到了这个: '-id:wg%20+id:br%20-id:c' 但它只得到黑卡,而不是黑卡和红卡。我还尝试了 '-id:wgu%20+id:br%20-id:c' 因为我意识到我忘记了蓝色,但随后它只返回 404。

文档中是否有一个页面我没有找到解释如何仅搜索特定颜色,或者如何调用特定颜色标识而不在搜索中包含任何其他颜色标识?

python api
1个回答
0
投票

您可以在此处

看到指挥官颜色选项

高级搜索

Commander Color
enter image description here

https://scryfall.com/search?as=grid&order=name&q=commander:{color characters}+(game:paper)&page={number}
颜色 性格
白色 W
蓝色
黑色 B
红色 R
绿色 G
无色 C

示例

White color commander cards

https://scryfall.com/search?as=grid&order=name&q=commander:W+(game:paper)&page=1

White and Red colors commander cards

https://scryfall.com/search?as=grid&order=name&q=commander:WR+(game:paper)&page=1

结果

White color commander cards

第 1 页的卡片 enter image description here

特定卡 enter image description here

获取JSON数据 enter image description here

enter image description here

// 20240516230035
// https://api.scryfall.com/cards/e882c9f9-bf30-46b6-bedc-379d2c80e5cb?format=json&pretty=true

{
  "object": "card",
  "id": "e882c9f9-bf30-46b6-bedc-379d2c80e5cb",
  "oracle_id": "629fe1be-272d-465f-b9b1-2ce177410f13",
  "multiverse_ids": [
    
  ],
  "mtgo_id": 91504,
  "arena_id": 77106,
  "tcgplayer_id": 243201,
  "cardmarket_id": 571299,
  "name": "+2 Mace",
  "lang": "en",
  "released_at": "2021-07-23",
  "uri": "https://api.scryfall.com/cards/e882c9f9-bf30-46b6-bedc-379d2c80e5cb",
  "scryfall_uri": "https://scryfall.com/card/afr/1/+2-mace?utm_source=api",
  "layout": "normal",
  "highres_image": true,
  "image_status": "highres_scan",
  "image_uris": {
    "small": "https://cards.scryfall.io/small/front/e/8/e882c9f9-bf30-46b6-bedc-379d2c80e5cb.jpg?1627701221",
    "normal": "https://cards.scryfall.io/normal/front/e/8/e882c9f9-bf30-46b6-bedc-379d2c80e5cb.jpg?1627701221",
    "large": "https://cards.scryfall.io/large/front/e/8/e882c9f9-bf30-46b6-bedc-379d2c80e5cb.jpg?1627701221",
    "png": "https://cards.scryfall.io/png/front/e/8/e882c9f9-bf30-46b6-bedc-379d2c80e5cb.png?1627701221",
    "art_crop": "https://cards.scryfall.io/art_crop/front/e/8/e882c9f9-bf30-46b6-bedc-379d2c80e5cb.jpg?1627701221",
    "border_crop": "https://cards.scryfall.io/border_crop/front/e/8/e882c9f9-bf30-46b6-bedc-379d2c80e5cb.jpg?1627701221"
  },
  "mana_cost": "{1}{W}",
  "cmc": 2.0,
  "type_line": "Artifact — Equipment",
  "oracle_text": "Equipped creature gets +2/+2.\nEquip {3} ({3}: Attach to target creature you control. Equip only as a sorcery.)",
  "colors": [
    "W"
  ],
  "color_identity": [
    "W"
  ],
  "keywords": [
    "Equip"
  ],
  "legalities": {
    "standard": "not_legal",
    "future": "not_legal",
    "historic": "legal",
    "timeless": "legal",
    "gladiator": "legal",
    "pioneer": "legal",
    "explorer": "legal",
    "modern": "legal",
    "legacy": "legal",
    "pauper": "legal",
    "vintage": "legal",
    "penny": "not_legal",
    "commander": "legal",
    "oathbreaker": "legal",
    "standardbrawl": "not_legal",
    "brawl": "legal",
    "alchemy": "not_legal",
    "paupercommander": "legal",
    "duel": "legal",
    "oldschool": "not_legal",
    "premodern": "not_legal",
    "predh": "not_legal"
  },
  "games": [
    "arena",
    "paper",
    "mtgo"
  ],
  "reserved": false,
  "foil": true,
  "nonfoil": true,
  "finishes": [
    "nonfoil",
    "foil"
  ],
  "oversized": false,
  "promo": false,
  "reprint": false,
  "variation": false,
  "set_id": "e1ef87ba-ba92-4573-817f-543b996d2851",
  "set": "afr",
  "set_name": "Adventures in the Forgotten Realms",
  "set_type": "expansion",
  "set_uri": "https://api.scryfall.com/sets/e1ef87ba-ba92-4573-817f-543b996d2851",
  "set_search_uri": "https://api.scryfall.com/cards/search?order=set&q=e%3Aafr&unique=prints",
  "scryfall_set_uri": "https://scryfall.com/sets/afr?utm_source=api",
  "rulings_uri": "https://api.scryfall.com/cards/e882c9f9-bf30-46b6-bedc-379d2c80e5cb/rulings",
  "prints_search_uri": "https://api.scryfall.com/cards/search?order=released&q=oracleid%3A629fe1be-272d-465f-b9b1-2ce177410f13&unique=prints",
  "collector_number": "1",
  "digital": false,
  "rarity": "common",
  "flavor_text": "The weight of this magic weapon falls heavy on the wicked.",
  "card_back_id": "0aeebaf5-8c7d-4636-9e82-8c27447861f7",
  "artist": "Jarel Threat",
  "artist_ids": [
    "0fd89fbd-bd59-4ded-890e-731a8982f278"
  ],
  "illustration_id": "444cd469-4a05-4a58-a098-8af8a7b0f886",
  "border_color": "black",
  "frame": "2015",
  "full_art": false,
  "textless": false,
  "booster": true,
  "story_spotlight": false,
  "edhrec_rank": 14852,
  "preview": {
    "source": "Wizards of the Coast",
    "source_uri": "https://twitter.com/MTG_Arena/status/1410327287317270534",
    "previewed_at": "2021-07-01"
  },
  "prices": {
    "usd": "0.02",
    "usd_foil": "0.05",
    "usd_etched": null,
    "eur": "0.07",
    "eur_foil": "0.15",
    "tix": "0.03"
  },
  "related_uris": {
    "tcgplayer_infinite_articles": "https://tcgplayer.pxf.io/c/4931599/1830156/21018?subId1=api&trafcat=infinite&u=https%3A%2F%2Finfinite.tcgplayer.com%2Fsearch%3FcontentMode%3Darticle%26game%3Dmagic%26partner%3Dscryfall%26q%3D%252B2%2BMace",
    "tcgplayer_infinite_decks": "https://tcgplayer.pxf.io/c/4931599/1830156/21018?subId1=api&trafcat=infinite&u=https%3A%2F%2Finfinite.tcgplayer.com%2Fsearch%3FcontentMode%3Ddeck%26game%3Dmagic%26partner%3Dscryfall%26q%3D%252B2%2BMace",
    "edhrec": "https://edhrec.com/route/?cc=%2B2+Mace"
  },
  "purchase_uris": {
    "tcgplayer": "https://tcgplayer.pxf.io/c/4931599/1830156/21018?subId1=api&u=https%3A%2F%2Fwww.tcgplayer.com%2Fproduct%2F243201%3Fpage%3D1",
    "cardmarket": "https://www.cardmarket.com/en/Magic/Products/Singles/Adventures-in-the-Forgotten-Realms/2-Mace?referrer=scryfall&utm_campaign=card_prices&utm_medium=text&utm_source=scryfall",
    "cardhoarder": "https://www.cardhoarder.com/cards/91504?affiliate_id=scryfall&ref=card-profile&utm_campaign=affiliate&utm_medium=card&utm_source=scryfall"
  }
}
© www.soinside.com 2019 - 2024. All rights reserved.