this post was submitted on 18 Oct 2025
5 points (85.7% liked)

MTG

2316 readers
11 users here now

Magic: the Gathering discussion

General discussion, questions, and media related to Magic: the Gathering that doesn't fit within a more specific community. Our equivalent of /r/magicTCG!

Type [[Card name]] in your posts and comments and CardBot will reply with a link to the card! More info here.

founded 2 years ago
MODERATORS
 

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?

top 4 comments
sorted by: hot top controversial new old
[–] counterspell@mtgzone.com 1 points 2 days ago

✅ This will create a fully Moxfield-compatible CSV with all cards from a Scryfall search.

import requests
import csv
import time

QUERY = "f:standard f:penny usd<=1"
BASE_URL = "https://api.scryfall.com/cards/search"
PARAMS = {
    "q": QUERY,
    "unique": "cards",
    "format": "json"
}

OUTPUT_FILE = "moxfield_import.csv"

FIELDNAMES = [
    "Count",
    "Tradelist Count",
    "Name",
    "Edition",
    "Condition",
    "Language",
    "Foil",
    "Tags",
    "Last Modified",
    "Collector Number",
    "Alter",
    "Proxy",
    "Purchase Price"
]

def fetch_all_cards():
    url = BASE_URL
    params = PARAMS.copy()
    while True:
        resp = requests.get(url, params=params)
        resp.raise_for_status()
        data = resp.json()
        for card in data.get("data", []):
            yield card
        if not data.get("has_more"):
            break
        url = data["next_page"]
        params = None
        time.sleep(0.2)

def write_cards_to_csv(filename):
    with open(filename, "w", newline="", encoding="utf-8") as f:
        writer = csv.DictWriter(f, fieldnames=FIELDNAMES)
        writer.writeheader()
        for card in fetch_all_cards():
            row = {
                "Count": 1,
                "Tradelist Count": "",
                "Name": card.get("name"),
                "Edition": card.get("set"),
                "Condition": "",
                "Language": card.get("lang"),
                "Foil": "Yes" if card.get("foil") else "No",
                "Tags": "",
                "Last Modified": "",
                "Collector Number": card.get("collector_number"),
                "Alter": "",
                "Proxy": "",
                "Purchase Price": ""
            }
            writer.writerow(row)

if __name__ == "__main__":
    write_cards_to_csv(OUTPUT_FILE)
    print(f"Saved all cards to {OUTPUT_FILE}")
[–] counterspell@mtgzone.com 2 points 4 days ago* (last edited 4 days 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 1 points 4 days ago (1 children)

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.

[–] counterspell@mtgzone.com 1 points 4 days ago* (last edited 4 days 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.