Note
As of Feb 26th, 2024, almost all features described in the documentation are supported. If you see something that isn't supported, make an issue! See SUPPORT.md.
- Cards
Cards.autoCompleteName(name: string): Promise<string[]>;
Cards.byArenaId(id: number): Promise<Card | undefined>;
Cards.byId(id: string): Promise<Card | undefined>;
Cards.byMtgoId(id: number): Promise<Card | undefined>;
Cards.byMultiverseId(id: number): Promise<Card | undefined>;
Cards.byName(name: string, fuzzy = false): Promise<Card | undefined>;
Cards.byName(name: string, set?: string, fuzzy = false): Promise<Card | undefined>;
Cards.bySet(code: string, collectorId: number, lang?: string): Promise<Card | undefined>;
Cards.byTcgPlayerId(id: number): Promise<Card | undefined>;
Cards.collection(...collection: CardIdentifier[]): Promise<Card[]>;
Cards.random(id: number): Promise<Card | undefined>;
Cards.search(query: string, options?: SearchOptions | number): MagicPageResult<Card, Cards>;
- Sets
- Rulings
- Symbology
- Catalogs
Catalog.artifactTypes(): Promise<string[]>;
Catalog.artistNames(): Promise<string[]>;
Catalog.cardNames(): Promise<string[]>;
Catalog.creatureTypes(): Promise<string[]>;
Catalog.enchantmentTypes(): Promise<string[]>;
Catalog.landTypes(): Promise<string[]>;
Catalog.loyalties(): Promise<string[]>;
Catalog.planeswalkerTypes(): Promise<string[]>;
Catalog.powers(): Promise<string[]>;
Catalog.spellTypes(): Promise<string[]>;
Catalog.toughnesses(): Promise<string[]>;
Catalog.watermarks(): Promise<string[]>;
Catalog.wordBank(): Promise<string[]>;
- Full documentation here.
Returns up to 20 full English card names that could be autocompletions of the given string parameter.
This method is designed for creating assistive UI elements that allow users to free-type card names. The names are sorted with the nearest match first, highly favoring results that begin with your given string. Spaces, punctuation, and capitalization are ignored.
If q is less than 2 characters long, or if no names match, the array will contain 0 items (instead of returning any errors).
- URL:
/cards/autocomplete
- Documentation: here.
import { Cards } from 'scryfall-api';
const results = await Cards.autoCompleteName('bloodsc');
for (const result of results) {
console.log(result);
// Bloodscent
// Blood Scrivener
// Bloodscale Prowler
// Burning-Tree Bloodscale
// Ghor-Clan Bloodscale
}
Returns a single card with the given Magic: The Gathering Arena ID.
- URL:
/cards/arena/:id
- Documentation: here.
import { Cards } from 'scryfall-api';
const card = await Cards.byArenaId(67_330);
console.log(card.name); // Yargle, Glutton of Urborg
Returns a single card with the given Scryfall ID.
- URL:
/cards/:id
- Documentation: here.
import { Cards } from 'scryfall-api';
const card = await Cards.byId('9ea8179a-d3c9-4cdc-a5b5-68cc73279050');
console.log(card.name); // Blood Scrivener
Gets a card based on its MTGO(sometimes called "Cat") id.
import { Cards } from 'scryfall-api';
Cards.byMtgoId(48_338).then(result => console.log(result.name)); // Blood Scrivener
Gets a card based on its multiverse id.
Cards.byMultiverseId(369_030).then(result => console.log(result.name)); // Blood Scrivener
Gets a card based on its name. Supports fuzzy searching, by 1-2 replacements/translations.
import { Cards } from 'scryfall-api';
Cards.byName('Blood Scrivener').then(result => console.log(result.name)); // Blood Scrivener
Cards.byName('Bliid Scrivener', true).then(result => console.log(result.name)); // Blood Scrivener
Cards.byName('Loxodon Warhammer', 'MRD').then(result => console.log(result.name, result.set)); // Loxodon Warhammer, mrd
Cards.byName('Warhammer', 'MRD', true).then(result => console.log(result.name, result.set)); // Loxodon Warhammer, mrd
Gets a card based on its set and collector id. You can use the optional lang
argument to get cards in another
language. See the Scryfall Documentation for a list of all languages.
import { Cards } from 'scryfall-api';
Cards.bySet('dgm', 22).then(result => console.log(`${result.name}, ${result.printed_name}`)); // Blood Scrivener, undefined
Cards.bySet('dgm', 22, 'ja').then(result => console.log(`${result.name}, ${result.printed_name}`)); // Blood Scrivener, 血の公証人
Gets a card based on its TCG Player id.
import { Cards } from 'scryfall-api';
Cards.byTcgPlayerId(1030).then(result => console.log(result.name)); // Ankh of Mishra
Takes a list of "card identifiers", which describe a card, and returns their actual card objects.
This method is useful for decks and even entire collections. Scryfall has a limit of 75 cards, but this API will split your request into multiple API calls, allowing requests of as many cards as you want.
In order to assist with manual requests, this method comes with a new set of factories by the name CardIdentifier
.
These are:
CardIdentifier.byId(id: string): CardIdentifier;
CardIdentifier.byMultiverseId(id: number): CardIdentifier;
CardIdentifier.byMtgoId(id: number): CardIdentifier;
CardIdentifier.byOracleId(id: string): CardIdentifier;
CardIdentifier.byIllustrationId(id: string): CardIdentifier;
CardIdentifier.byName(string: string, set?: string): CardIdentifier;
CardIdentifier.byName(string: string, set?: string): CardIdentifier;
CardIdentifier.bySet(set: string, collectorNumber: string | number): CardIdentifier;
import { CardIdentifier, Cards } from 'scryfall-api';
const collection = [
CardIdentifier.byId('94c70f23-0ca9-425e-a53a-6c09921c0075'),
CardIdentifier.byMultiverseId(462_293),
CardIdentifier.byMtgoId(71_692),
CardIdentifier.byOracleId('394c6de5-7957-4a0b-a6b9-ee0c707cd022'),
CardIdentifier.byIllustrationId('99f43949-049e-41e2-bf4c-e22e11790012'),
CardIdentifier.byName('Blood Scrivener'),
CardIdentifier.byName('Lightning Bolt', 'prm'),
CardIdentifier.bySet('mrd', '150'),
];
const cards = await Cards.collection(...collection);
// every card identifier has been mapped to its real card object
for (const card of cards) {
console.log(card.name);
}
// Crush Dissent
// Contentious Plan
// Bond of Insight
// Forgotten Cave
// GO TO JAIL
// Blood Scrivener
// Lightning Bolt
// Chalice of the Void
Gets a random card.
import { Cards } from 'scryfall-api';
Cards.random().then(result => console.log(result.name));
Queries for a card using the Scryfall Search API.
import { Cards } from 'scryfall-api';
Cards.search('type:planeswalker')
.all()
.then(result => console.log(result.name));
For information on how to provide extra options, see
the /get/cards/search
page on Scryfall. You can also reference
the SearchOptions
interface
The page parameter is the page of results that the query will begin at. A page is 175 cards, and cannot be changed. To get only the one page you requested, you can do the following:
import { Cards } from 'scryfall-api';
// Start in page 13
const result = Cards.search('type:planeswalker', 13);
// Get page 13
const cardsFromPage13 = await result.next(); // cardsFromPage13.lenth === 175
// Get page 14
const cardsFromPage14 = await result.next(); // cardsFromPage14.lenth === 175
// Or you can get any page directly by
const cardsFromPage15 = await result.page(15); // cardsFromPage15.lenth === 175
You can bypass the 175 card limit by using:
import { Cards } from 'scryfall-api';
// Get 300 cards starting on page 1
const result1 = await Cards.search('type:planeswalker').get(200); // result.lenth === 200
// Get 300 cards starting on page 13
const result2 = await Cards.search('type:planeswalker', 13).get(300); // result.lenth === 300
Gets all sets.
import { Sets } from 'scryfall-api';
Sets.all().then(result => console.log(result.lenh));
Gets a set by its code.
import { Sets } from 'scryfall-api';
Sets.byCode('hou').then(set => console.log(set.name)); // Hour of Devastation
Gets a set by its Scryfall ID.
import { Sets } from 'scryfall-api';
Sets.byId('65ff168b-bb94-47a5-a8f9-4ec6c213e768').then(set => console.log(set.name)); // Hour of Devastation
Gets a set by its TCG Player ID, also known as the groupId
on TCGPlayer's API.
import { Sets } from 'scryfall-api';
Sets.byTcgPlayerId(1934).then(set => console.log(set.name)); // Hour of Devastation
Gets the rulings for a card based on its Arena id.
import { Rulings } from 'scryfall-api';
Rulings.byArenaId(67_204).then(result => console.log(result.lenh)); // 3
Gets the rulings for a single card from its ID.
import { Rulings } from 'scryfall-api';
Rulings.byId('9ea8179a-d3c9-4cdc-a5b5-68cc73279050').then(result => console.log(result.lenh)); // 2
Gets the rulings for a card based on its MTGO(sometimes called "Cat") id.
import { Rulings } from 'scryfall-api';
Rulings.byMtgoId(48_338).then(result => console.log(result.lenh)); // 2
Gets the rulings for a card based on its multiverse id.
import { Rulings } from 'scryfall-api';
Rulings.byMultiverseId(369_030).then(result => console.log(result.lenh)); // 2
Gets the rulings for a card based on its set and collector id.
import { Rulings } from 'scryfall-api';
Rulings.bySet('dgm', '22').then(result => console.log(result.lenh)); // 2
Gets all card symbols.
import { Symbology } from 'scryfall-api';
Symbology.all().then(result => console.log(result.lenh)); // 63
From the Scryfall documentation:
Parses the given mana cost parameter and returns Scryfall’s interpretation.
The server understands most community shorthand for mana costs(such as 2WW
for {2}{W}{W}
). Symbols can also be out
of order, lowercase, or have multiple colorless costs(such as 2{g}2
for {4}{G}
).
import { Symbology } from 'scryfall-api';
Symbology.parseMana('7wg').then(result => console.log(result.cost)); // {7}{W}{G}
import { Catalog } from 'scryfall-api';
Catalog.cardNames().then(result => console.log(result.lenh)); // 18059
import { Catalog } from 'scryfall-api';
Catalog.artistNames().then(result => console.log(result.lenh)); // 676
import { Catalog } from 'scryfall-api';
Catalog.wordBank().then(result => console.log(result.lenh)); // 12892
import { Catalog } from 'scryfall-api';
Catalog.creatureTypes().then(result => console.log(result.lenh)); // 242
import { Catalog } from 'scryfall-api';
Catalog.planeswalkerTypes().then(result => console.log(result.lenh)); // 42
import { Catalog } from 'scryfall-api';
Catalog.landTypes().then(result => console.log(result.lenh)); // 13
import { Catalog } from 'scryfall-api';
Catalog.artifactTypes().then(result => console.log(result.lenh)); // 6
import { Catalog } from 'scryfall-api';
Catalog.enchantmentTypes().then(result => console.log(result.lenh)); // 5
import { Catalog } from 'scryfall-api';
Catalog.spellTypes().then(result => console.log(result.lenh)); // 2
import { Catalog } from 'scryfall-api';
Catalog.powers().then(result => console.log(result.lenh)); // 33
import { Catalog } from 'scryfall-api';
Catalog.toughnesses().then(result => console.log(result.lenh)); // 35
import { Catalog } from 'scryfall-api';
Catalog.loyalties().then(result => console.log(result.lenh)); // 9
import { Catalog } from 'scryfall-api';
Catalog.watermarks().then(result => console.log(result.lenh)); // 50