A Python script to fetch Magic: The Gathering cards from Scryfall API, with support for multiple formats and flexible search options.
- Search cards from specific Magic: The Gathering sets
- Filter by game format (Standard, Modern, Legacy, etc.)
- Display cards with customizable number of copies
- Generate deck lists in a standard format
- Export results to text files
- Color filtering support
- Respects Scryfall API rate limits
- Comprehensive error handling
- Standard
- Modern
- Legacy
- Vintage
- Commander
- Pauper
- Pioneer
- Brawl
- Historic
- Penny
- Command Line Interface (CLI) with comprehensive arguments
- Interactive mode with guided input
- Automatic fallback to interactive mode when no arguments provided
- Python 3.6+
requests
library
- Clone the repository:
git clone https://github.com/yourusername/pyScryfall.git
cd pyScryfall
- Install required packages:
pip install requests
# Basic usage with CLI arguments
python pyscryfall.py --set neo --format pauper --copies 4
# Full example with all options
python pyscryfall.py --set neo --format modern --copies 4 --colors ur --output deck.txt --verbose
# Show help
python pyscryfall.py --help
# Launch in interactive mode
python pyscryfall.py
The interactive mode will guide you through:
- Set selection
- Format selection
- Number of copies
- Color filtering
- Output file specification
- Verbose mode toggle
Argument | Short | Description | Default |
---|---|---|---|
--set | -s | Set code (e.g., neo) | Required |
--format | -f | Game format | pauper |
--copies | -c | Number of copies (0-4) | 0 |
--colors | -col | Color filter (w,u,b,r,g) | None |
--output | -o | Output file path | None |
--verbose | -v | Enable verbose output | False |
--version | Show version |
- With copies > 0:
N Card Name (SET)
- With copies = 0:
Card Name (SET)
Example output:
4 Lightning Bolt (DMR)
Consider (MID)
4 Counterspell (DMR)
This project uses the Scryfall API. The script implements:
- Card search endpoint
- Format filtering
- Set-based filtering
- Color filtering
- Automatic pagination handling
- Fork the repository
- Create your feature branch:
git checkout -b feature/new-feature
- Commit your changes:
git commit -am 'Add new feature'
- Push to the branch:
git push origin feature/new-feature
- Submit a pull request
This work is licensed under Attribution-Only License.
You are free to:
- Use, modify, and distribute this software for any purpose (including commercial use)
- Include this software in other projects
- Change the software to suit your needs
Under the following terms:
- You must give appropriate credit to the original author (Andrea Pede)
- Attribution must include the original author's name and a link to the original repository
- Scryfall for providing the API and card data
- Magic: The Gathering and all card names are trademarks of Wizards of the Coast