Home
| Colors: |
March 2026

A `jq` Filter for Card Types from Archidekt JSON Feeds

I'm making my own Magic: The Gathering deck maker. It's based on feeds from Archidekt.

The process I'm doing is to make big collections of cards for each color/color-combination to start with. I filter those down to make actual decks.

My first step was to split things my existing decks into the colors/combos. I did that by pulling down the Archidekt JSON data from their API. Then, I used jq to filter the decks and pull out the names for each set.

Single Color Cards

For example, Green:

cat tmp.json | jq -r '.cards[] 
| select(.card.oracleCard.colors | length == 1) 
| select(.card.oracleCard.colors | any(index("Green") )) 
| .card.oracleCard.name' > green-names.txt

Multi Color

For example, Green and Black for "Golgari"

cat input.json | jq -r '.cards[]
| select(.card.oracleCard.colorIdentity | length == 2) 
| select(.card.oracleCard.colorIdentity | any(index("Black"))) 
| select(.card.oracleCard.colorIdentity | any(index("Green"))) 
| .card.oracleCard.name' > golgari-names.txt

I've used jq a few times before. This is the first time I used it to filter things based on values nested inside objects. It's super impressive.

-a

end of line

References

The Archidekt API

Archidekt doesn't mind folks poking at their API. You can use the ID of a deck in a URL like this to get the JSON for it:

https://archidekt.com/api/decks/20588790/

The only way to fly when you need to mess with JSON on the command line.