I want to play a custom MTG format where the card pool is defined by a Scryfall search and updated twice a year. For example, my search might be f:standard f:penny usd<=1.

How can I export, share, and import the list of legal cards with other people so that we can all check card legality and use a deck builder with the same pool of cards?

  • counterspellOP
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    7 hours ago

    My first try was using this script:
    Query Scryfall + dump card names out for easy import into Moxfield

    ❯ python scryfall_search.py -q "f:standard f:penny usd<=1" --output-as-file "$HOME/desktop/out.csv"
    Running Scryfall search on f:standard f:penny usd<=1 legal:commander
    Found 1,197 total matches!
    

    But when I tried importing the output csv in Moxfield, I got a bunch of No card name found on line x errors.

  • MysticKetchup@lemmy.world
    link
    fedilink
    arrow-up
    1
    ·
    9 hours ago

    If you do a Scryfall search the URL will match the parameters of the search. So you can just copy and share the link.

    Scryfall will update Standard/Penny Dreadful rotation and price as it changes, so the list will always be current.

    • counterspellOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      edit-2
      9 hours ago

      The list needs to be static. How can you create decks for a format that is constantly changing? What I need is a way to share a consistent list of legal cards so that everyone can search within the same list, rather than each person having a different version.

  • chgxvjh [he/him, comrade/them]@hexbear.net
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    11 hours ago

    That’s pretty straightforward with Powershell

    $url = 'https://api.scryfall.com/cards/search?q=f%3Astandard f:penny usd<=1'
    $data = @()
    
    DO {
        $response = $(Invoke-WebRequest $url).Content | ConvertFrom-Json
        $data = $data + $response.data
        $url = $response.next_page
    } WHILE ($response.has_more)
    
    
    FOREACH ($card in $data) {
        ECHO $card.name
    }
    

    This gives you a plain list of card names

    • counterspellOP
      link
      fedilink
      English
      arrow-up
      2
      ·
      edit-2
      9 hours ago

      Is there a deckbuilder that allows using just that list to build decks? How would I import it?

      #!/bin/bash
      
      url="https://api.scryfall.com/cards/search?q=f%3Astandard+f%3Apenny+usd<=1"
      data=()
      
      while [ -n "$url" ]; do
          response=$(curl -s "$url")
          data_chunk=$(echo "$response" | jq -c '.data[]')
          while read -r card; do
              data+=("$card")
          done <<< "$data_chunk"
      
          has_more=$(echo "$response" | jq -r '.has_more')
          if [ "$has_more" = "true" ]; then
              url=$(echo "$response" | jq -r '.next_page')
          else
              url=""
          fi
      done
      
      for card_json in "${data[@]}"; do
          echo "$card_json" | jq -r '.name'
      done