Important
ManaQL is not meant to be a replacement for Scryfall, and was intended to be a minimally-viable-replacement for the usecase highlighted.
manaql is a GraphQL API for Magic: The Gathering cards, powered by the Scryfall API.
It currently supports basic search features (see the example queries section below) for Magic: The Gathering web applications, namely:
- get cards and all their printings, by card name(s)
- autocomplete card names
I built this to be used by bling-my-deck, which has a need to query for {cards and all their printings, by card name}, which wasn't supported by Scryfall.
also, as a learning experience!
check out manaql-ingest for the data ingestion pipeline!
- clone this repo
- run
pnpm i
- run
pnpm dev:db
- run
pnpm dev
- visit http://localhost:4000/graphql in your browser
- run
pnpm test:db:down
- run
pnpm test:db
- run
pnpm test
POST https://api.manaql.com/graphql
Get cards by name and all of their printings
query Cards($filter: CardFilter!, $first: Int) {
cards(filter: $filter, first: $first) {
edges {
node {
cardId
name
mainType
printings {
edges {
node {
id
set
imageUri
}
}
}
}
}
}
}
{
"filter": {
"fields": ["name"],
"operator": "eq",
"query": [
"Animate Dead",
"Arachnogenesis",
"Assassin's Trophy",
"Azusa, Lost but Seeking",
"Bala Ged Recovery",
"Baba Lysaga, Night Witch"
]
},
"first": 10
}
Get cards by name and all of their printings, filtering by certain finishes and sets
query ExcludeCertainFinishesAndSets($filter: CardFilter!, $first: Int, $filters: [PrintingFilter!]) {
cards(filter: $filter, first: $first) {
edges {
node {
cardId
name
mainType
printings(filters: $filters) {
edges {
node {
id
set
imageUri
finishes
set
}
}
}
}
}
}
}
{
"filter": {
"fields": ["name"],
"operator": "eq",
"query": [
"Animate Dead",
"Arachnogenesis",
"Assassin's Trophy",
"Azusa, Lost but Seeking",
"Bala Ged Recovery",
"Baba Lysaga, Night Witch"
]
},
"first": 10,
"filters": [
{
"fields": "set",
"operator": "ne",
"query": [
"sld"
]
},
{
"fields": "finishes",
"operator": "co",
"query": ["nonfoil", "foil"] // if you want to exclude a finish, just don't include it in the query
}
]
}
Autocomplete/typeahead
query Autocomplete($filter: CardFilter!, $first: Int) {
cards(filter: $filter, first: $first) {
edges {
node {
cardId
name
}
}
}
}
{
"filter": {
"fields": ["name"],
"query": ["Baba Ly"],
"operator": "sw"
},
"first": 10
}
{
"data": {
"cards": {
"edges": [
{
"node": {
"cardId": "10561",
"name": "Baba Lysaga, Night Witch"
}
}
]
}
}
}
TODO:
- better fuzzy searching