scryfall-api 4.0.5 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021-2025 MarioMH
3
+ Copyright (c) 2021-2026 MarioMH
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -93,6 +93,8 @@ Compile the project
93
93
  bun run build
94
94
  ```
95
95
 
96
+ You can read the full [contribution](./CONTRIBUTING.md) guidelines.
97
+
96
98
  ## MIT License
97
99
 
98
- [Copyright 2021-2025 MarioMH](./LICENSE)
100
+ [Copyright 2021-2026 MarioMH](./LICENSE)
@@ -0,0 +1,447 @@
1
+ type TOrArrayOfT<T> = T | T[];
2
+ /**
3
+ * Type definition for Nullable.
4
+ * @type {T | null | undefined} The type can be T, null, or undefined.
5
+ * @template T The type of the value that can be null or undefined.
6
+ */
7
+ type Nullable<T> = null | T | undefined;
8
+ type ParameterValue = boolean | number | string | undefined;
9
+ type FetcherParameters = Record<string, ParameterValue>;
10
+ type TFetcher = <TData>(apiPath: TOrArrayOfT<number | string | undefined>, parameters?: FetcherParameters, body?: object) => Promise<TData | undefined>;
11
+ type QueryValue = boolean | number | string | undefined;
12
+ interface PageQuery {
13
+ [key: string]: QueryValue;
14
+ page: number;
15
+ }
16
+ declare class MagicPageResult<T> {
17
+ #private;
18
+ private readonly apiPath;
19
+ private readonly query;
20
+ private readonly fetcher;
21
+ constructor(apiPath: string, query: PageQuery, fetcher?: TFetcher);
22
+ get count(): number;
23
+ get hasMore(): boolean;
24
+ all(): Promise<T[]>;
25
+ get(limit: number): Promise<T[]>;
26
+ next(): Promise<T[]>;
27
+ page(page: number): Promise<T[]>;
28
+ private setNextPage;
29
+ }
30
+ interface CardIdentifierId {
31
+ id: string;
32
+ }
33
+ interface CardIdentifierIllustrationId {
34
+ illustration_id: string;
35
+ }
36
+ interface CardIdentifierMtgGoId {
37
+ mtgo_id: number;
38
+ }
39
+ interface CardIdentifierMultiverseId {
40
+ multiverse_id: number;
41
+ }
42
+ interface CardIdentifierNameSet {
43
+ name: string;
44
+ set?: string;
45
+ }
46
+ interface CardIdentifierOracleId {
47
+ oracle_id: string;
48
+ }
49
+ interface CardIdentifierCollectorSet {
50
+ collector_number: string;
51
+ set: string;
52
+ }
53
+ type CardIdentifier = CardIdentifierCollectorSet | CardIdentifierId | CardIdentifierIllustrationId | CardIdentifierMtgGoId | CardIdentifierMultiverseId | CardIdentifierNameSet | CardIdentifierOracleId;
54
+ declare class CardIdentifierApi {
55
+ static byId(id: string): CardIdentifier;
56
+ static byIllustrationId(id: string): CardIdentifier;
57
+ static byMtgoId(id: number): CardIdentifier;
58
+ static byMultiverseId(id: number): CardIdentifier;
59
+ static byName(name: string, set?: string): CardIdentifier;
60
+ static byOracleId(id: string): CardIdentifier;
61
+ static bySet(set: string, collectorNumber: number | string): CardIdentifier;
62
+ }
63
+ type CardLanguage = 'ar' | 'de' | 'en' | 'es' | 'fr' | 'grc' | 'he' | 'it' | 'ja' | 'ko' | 'la' | 'ph' | 'pt' | 'ru' | 'sa' | 'zhs' | 'zht';
64
+ type CardLayout = 'adventure' | 'art_series' | 'augment' | 'battle' | 'case' | 'class' | 'double_faced_token' | 'emblem' | 'flip' | 'host' | 'leveler' | 'meld' | 'modal_dfc' | 'mutate' | 'normal' | 'planar' | 'prototype' | 'reversible_card' | 'saga' | 'scheme' | 'split' | 'token' | 'transform' | 'vanguard';
65
+ interface CardCore {
66
+ arena_id?: Nullable<string>;
67
+ cardmarket_id?: Nullable<number>;
68
+ id: string;
69
+ lang: CardLanguage;
70
+ layout: CardLayout;
71
+ mtgo_foil_id?: Nullable<number>;
72
+ mtgo_id?: Nullable<number>;
73
+ multiverse_ids?: Nullable<number[]>;
74
+ object: 'card';
75
+ oracle_id?: Nullable<string>;
76
+ prints_search_uri: string;
77
+ rulings_uri: string;
78
+ scryfall_uri: string;
79
+ tcgplayer_etched_id?: Nullable<number>;
80
+ tcgplayer_id?: Nullable<number>;
81
+ uri: string;
82
+ }
83
+ type Color = 'B' | 'G' | 'R' | 'U' | 'W';
84
+ interface ManaCost {
85
+ cmc: number;
86
+ colorless: boolean;
87
+ colors: Color[];
88
+ cost: string;
89
+ monocolored: boolean;
90
+ multicolored: boolean;
91
+ object: 'mana_cost';
92
+ }
93
+ interface Symbology {
94
+ appears_in_mana_costs: boolean;
95
+ cmc: number;
96
+ colors: Color[];
97
+ english: string;
98
+ funny: boolean;
99
+ gatherer_alternates?: Nullable<string[]>;
100
+ hybrid: boolean;
101
+ loose_variant?: Nullable<string>;
102
+ mana_value?: Nullable<number>;
103
+ object: 'card_symbol';
104
+ phyrexian: boolean;
105
+ represents_mana: boolean;
106
+ svg_uri?: Nullable<string>;
107
+ symbol: string;
108
+ transposable: boolean;
109
+ }
110
+ declare class SymbologyApi {
111
+ all(): Promise<Symbology[]>;
112
+ parseMana(shorthand: string): Promise<ManaCost>;
113
+ }
114
+ declare const symbology: SymbologyApi;
115
+ interface ImageUris {
116
+ /**
117
+ *Size varies by card.
118
+ */
119
+ art: string;
120
+ /**
121
+ * @deprecated Use `art` instead. Removed on 2027-01-01.
122
+ * @see https://scryfall.com/blog/new-webp-images-jpeg-deprecations-237
123
+ */
124
+ art_crop: string;
125
+ /**
126
+ * @deprecated Use `crop` instead. Removed on 2027-01-01.
127
+ * @see https://scryfall.com/blog/new-webp-images-jpeg-deprecations-237
128
+ */
129
+ border_crop: string;
130
+ /**
131
+ *480 × 680.
132
+ */
133
+ crop: string;
134
+ /**
135
+ *672 × 936.
136
+ */
137
+ display: string;
138
+ /**
139
+ *488 × 680.
140
+ */
141
+ grid: string;
142
+ /**
143
+ *The only remaining JPEG size (488 × 680).
144
+ */
145
+ jpeg: string;
146
+ /**
147
+ * @deprecated Use `display` instead. Removed on 2027-01-01.
148
+ * @see https://scryfall.com/blog/new-webp-images-jpeg-deprecations-237
149
+ */
150
+ large: string;
151
+ /**
152
+ * @deprecated Use `grid` for WebP or `jpeg` for JPEG.
153
+ * @see https://scryfall.com/blog/new-webp-images-jpeg-deprecations-237
154
+ */
155
+ normal: string;
156
+ /**
157
+ *Still available, but hotlinking is not allowed after 2027-01-01.
158
+ */
159
+ png: string;
160
+ /**
161
+ * @deprecated Use `thumb` instead. Removed on 2027-01-01.
162
+ * @see https://scryfall.com/blog/new-webp-images-jpeg-deprecations-237
163
+ */
164
+ small: string;
165
+ /**
166
+ *146 × 204.
167
+ */
168
+ thumb: string;
169
+ }
170
+ type CardComponent = 'combo_piece' | 'meld_part' | 'meld_result' | 'token';
171
+ type Legality = 'banned' | 'legal' | 'not_legal' | 'restricted';
172
+ interface CardFace {
173
+ artist?: Nullable<string>;
174
+ artist_id?: Nullable<string>;
175
+ cmc?: Nullable<number>;
176
+ color_indicator?: Nullable<Color[]>;
177
+ colors?: Nullable<Color[]>;
178
+ defense?: Nullable<string>;
179
+ flavor_text?: Nullable<string>;
180
+ illustration_id?: Nullable<string>;
181
+ image_uris?: Nullable<ImageUris>;
182
+ layout?: Nullable<string>;
183
+ loyalty?: Nullable<string>;
184
+ mana_cost: string;
185
+ name: string;
186
+ object: 'card_face';
187
+ oracle_id?: Nullable<string>;
188
+ oracle_text?: Nullable<string>;
189
+ power?: Nullable<string>;
190
+ printed_name?: Nullable<string>;
191
+ printed_text?: Nullable<string>;
192
+ printed_type_line?: Nullable<string>;
193
+ toughness?: Nullable<string>;
194
+ type_line?: Nullable<string>;
195
+ watermark?: Nullable<string>;
196
+ }
197
+ interface RelatedCard {
198
+ component: CardComponent;
199
+ id: string;
200
+ name: string;
201
+ object: 'related_card';
202
+ type_line: string;
203
+ uri: string;
204
+ }
205
+ interface Legalities {
206
+ alchemy: Legality;
207
+ brawl: Legality;
208
+ commander: Legality;
209
+ duel: Legality;
210
+ explorer: Legality;
211
+ future: Legality;
212
+ gladiator: Legality;
213
+ historic: Legality;
214
+ legacy: Legality;
215
+ modern: Legality;
216
+ oathbreaker: Legality;
217
+ oldschool: Legality;
218
+ pauper: Legality;
219
+ paupercommander: Legality;
220
+ penny: Legality;
221
+ pioneer: Legality;
222
+ predh: Legality;
223
+ premodern: Legality;
224
+ standard: Legality;
225
+ standardbrawl: Legality;
226
+ timeless: Legality;
227
+ vintage: Legality;
228
+ }
229
+ interface GameplayCard {
230
+ all_parts?: Nullable<RelatedCard[]>;
231
+ card_faces?: Nullable<CardFace[]>;
232
+ cmc: number;
233
+ color_identity: Color[];
234
+ color_indicator?: Nullable<Color[]>;
235
+ colors?: Nullable<Color[]>;
236
+ defense?: Nullable<string>;
237
+ edhrec_rank?: Nullable<number>;
238
+ game_changer?: Nullable<boolean>;
239
+ hand_modifier?: Nullable<string>;
240
+ keywords: string[];
241
+ legalities: Legalities;
242
+ life_modifier?: Nullable<string>;
243
+ loyalty?: Nullable<string>;
244
+ mana_cost?: Nullable<string>;
245
+ name: string;
246
+ oracle_text?: Nullable<string>;
247
+ penny_rank?: Nullable<number>;
248
+ power?: Nullable<string>;
249
+ produced_mana?: Nullable<Color[]>;
250
+ reserved: boolean;
251
+ toughness?: Nullable<string>;
252
+ type_line: string;
253
+ }
254
+ type SetType = 'alchemy' | 'archenemy' | 'arsenal' | 'box' | 'commander' | 'core' | 'draft_innovation' | 'duel_deck' | 'expansion' | 'from_the_vault' | 'funny' | 'masterpiece' | 'masters' | 'memorabilia' | 'minigame' | 'planechase' | 'premium_deck' | 'promo' | 'spellbook' | 'starter' | 'token' | 'treasure_chest' | 'vanguard';
255
+ interface Set {
256
+ arena_code?: Nullable<string>;
257
+ block?: Nullable<string>;
258
+ block_code?: Nullable<string>;
259
+ card_count: number;
260
+ code: string;
261
+ digital: boolean;
262
+ foil_only: boolean;
263
+ icon_svg_uri: string;
264
+ id: string;
265
+ mtgo_code?: Nullable<string>;
266
+ name: string;
267
+ nonfoil_only: boolean;
268
+ object: 'set';
269
+ parent_set_code?: Nullable<string>;
270
+ printed_size?: Nullable<number>;
271
+ released_at?: Nullable<Date>;
272
+ scryfall_uri: string;
273
+ search_uri: string;
274
+ set_type: SetType;
275
+ tcgplayer_id?: Nullable<number>;
276
+ uri: string;
277
+ }
278
+ declare class SetApi {
279
+ all(): Promise<Set[]>;
280
+ byCode(code: string): Promise<Set | undefined>;
281
+ byId(id: string): Promise<Set | undefined>;
282
+ byTcgPlayerId(id: number): Promise<Set | undefined>;
283
+ }
284
+ declare const set: SetApi;
285
+ type BorderColor = 'black' | 'borderless' | 'gold' | 'silver' | 'white';
286
+ type Finish = 'etched' | 'foil' | 'nonfoil';
287
+ type Frame = '1993' | '1997' | '2003' | '2015' | 'future';
288
+ type FrameEffect = 'colorshifted' | 'companion' | 'compasslanddfc' | 'convertdfc' | 'devoid' | 'draft' | 'etched' | 'extendedart' | 'fandfc' | 'inverted' | 'legendary' | 'lesson' | 'miracle' | 'mooneldrazidfc' | 'nyxtouched' | 'originpwdfc' | 'shatteredglass' | 'showcase' | 'snow' | 'sunmoondfc' | 'tombstone' | 'upsidedowndfc' | 'waxingandwaningmoondfc';
289
+ type Game = 'arena' | 'mtgo' | 'paper';
290
+ type ImageStatus = 'highres_scan' | 'lowres' | 'missing' | 'placeholder';
291
+ interface Preview {
292
+ previewed_at: Date;
293
+ source: string;
294
+ source_uri: string;
295
+ }
296
+ interface Prices {
297
+ eur?: Nullable<string>;
298
+ eur_foil?: Nullable<string>;
299
+ tix?: Nullable<string>;
300
+ usd?: Nullable<string>;
301
+ usd_etched?: Nullable<string>;
302
+ usd_foil?: Nullable<string>;
303
+ }
304
+ type PromoType = 'arenaleague' | 'buyabox' | 'convention' | 'datestamped' | 'draftweekend' | 'duels' | 'event' | 'fnm' | 'gameday' | 'gateway' | 'giftbox' | 'instore' | 'intropack' | 'judgegift' | 'league' | 'openhouse' | 'ourney' | 'planeswalkerdeck' | 'playerrewards' | 'premiereshop' | 'prerelease' | 'release' | 'setpromo' | 'starterdeck' | 'wizardsplaynetwork';
305
+ interface PurchaseUris {
306
+ [key: string]: Nullable<string>;
307
+ cardhoarder?: Nullable<string>;
308
+ cardmarket?: Nullable<string>;
309
+ tcgplayer?: Nullable<string>;
310
+ }
311
+ type Rarity = 'bonus' | 'common' | 'mythic' | 'rare' | 'special' | 'uncommon';
312
+ interface RelatedUris {
313
+ [key: string]: Nullable<string>;
314
+ edhrec?: Nullable<string>;
315
+ gatherer?: Nullable<string>;
316
+ mtgtop8?: Nullable<string>;
317
+ tcgplayer_decks?: Nullable<string>;
318
+ tcgplayer_infinite_articles?: Nullable<string>;
319
+ tcgplayer_infinite_decks?: Nullable<string>;
320
+ }
321
+ type SecurityStamp = 'acorn' | 'arena' | 'circle' | 'heart' | 'oval' | 'triangle';
322
+ interface CardPrint {
323
+ artist?: Nullable<string>;
324
+ artist_ids?: Nullable<string[]>;
325
+ attraction_lights?: Nullable<number[]>;
326
+ booster: boolean;
327
+ border_color: BorderColor;
328
+ card_back_id: string;
329
+ collector_number: string;
330
+ content_warning?: Nullable<boolean>;
331
+ digital: boolean;
332
+ finishes: Finish[];
333
+ flavor_name?: Nullable<string>;
334
+ flavor_text?: Nullable<string>;
335
+ frame: Frame;
336
+ frame_effects?: Nullable<FrameEffect[]>;
337
+ full_art: boolean;
338
+ games: Game[];
339
+ highres_image: boolean;
340
+ illustration_id?: Nullable<string>;
341
+ image_status: ImageStatus;
342
+ image_uris?: Nullable<ImageUris>;
343
+ oversized: boolean;
344
+ preview: Preview;
345
+ prices: Prices;
346
+ printed_name?: Nullable<string>;
347
+ printed_text?: Nullable<string>;
348
+ printed_type_line?: Nullable<string>;
349
+ promo: boolean;
350
+ promo_types?: Nullable<PromoType[]>;
351
+ purchase_uris?: Nullable<PurchaseUris>;
352
+ rarity: Rarity;
353
+ related_uris: RelatedUris;
354
+ released_at: Date;
355
+ reprint: boolean;
356
+ scryfall_set_uri: string;
357
+ security_stamp?: Nullable<SecurityStamp>;
358
+ set: string;
359
+ set_id: string;
360
+ set_name: string;
361
+ set_search_uri: string;
362
+ set_type: SetType;
363
+ set_uri: string;
364
+ story_spotlight: boolean;
365
+ textless: boolean;
366
+ variation: boolean;
367
+ variation_of?: Nullable<string>;
368
+ watermark?: Nullable<string>;
369
+ }
370
+ type Card = CardCore & CardPrint & GameplayCard;
371
+ type CardSearchUnique = 'art' | 'cards' | 'prints';
372
+ type CardSearchOrder = 'artist' | 'cmc' | 'color' | 'edhrec' | 'eur' | 'name' | 'penny' | 'power' | 'rarity' | 'released' | 'review' | 'set' | 'tix' | 'toughness' | 'usd';
373
+ type CardSearchDirection = 'asc' | 'auto' | 'desc';
374
+ type CardSearchFormat = 'csv' | 'json';
375
+ interface CardSearch {
376
+ dir?: CardSearchDirection;
377
+ format?: CardSearchFormat;
378
+ include_extras?: boolean;
379
+ include_multilingual?: boolean;
380
+ include_variations?: boolean;
381
+ order?: CardSearchOrder;
382
+ page?: number;
383
+ pretty?: boolean;
384
+ unique?: CardSearchUnique;
385
+ }
386
+ declare class CardApi {
387
+ autoCompleteName(name: string): Promise<string[]>;
388
+ byArenaId(id: number): Promise<Card | undefined>;
389
+ byId(id: string): Promise<Card | undefined>;
390
+ byMtgoId(id: number): Promise<Card | undefined>;
391
+ byMultiverseId(id: number): Promise<Card | undefined>;
392
+ byName(name: string, isFuzzySearch?: boolean): Promise<Card | undefined>;
393
+ byName(name: string, set?: string, isFuzzySearch?: boolean): Promise<Card | undefined>;
394
+ bySet(set: string, collectorNumber: number, lang?: string): Promise<Card | undefined>;
395
+ byTcgPlayerId(id: number): Promise<Card | undefined>;
396
+ collection(...identifiers: CardIdentifier[]): Promise<Card[]>;
397
+ random(): Promise<Card>;
398
+ search(query: string, options?: CardSearch | number): MagicPageResult<Card>;
399
+ }
400
+ declare const cards: CardApi;
401
+ declare class CatalogApi {
402
+ artifactTypes(): Promise<string[]>;
403
+ artistNames(): Promise<string[]>;
404
+ cardNames(): Promise<string[]>;
405
+ creatureTypes(): Promise<string[]>;
406
+ enchantmentTypes(): Promise<string[]>;
407
+ landTypes(): Promise<string[]>;
408
+ loyalties(): Promise<string[]>;
409
+ planeswalkerTypes(): Promise<string[]>;
410
+ powers(): Promise<string[]>;
411
+ spellTypes(): Promise<string[]>;
412
+ toughnesses(): Promise<string[]>;
413
+ watermarks(): Promise<string[]>;
414
+ wordBank(): Promise<string[]>;
415
+ }
416
+ declare const catalog: CatalogApi;
417
+ export interface Catalog {
418
+ data: string[];
419
+ object: 'catalog';
420
+ total_values: number;
421
+ uri: string;
422
+ }
423
+ export interface Ruling {
424
+ comment: string;
425
+ object: 'ruling';
426
+ oracle_id: string;
427
+ published_at: Date;
428
+ source: string;
429
+ }
430
+ declare class RulingApi {
431
+ byArenaId(id: number): Promise<Ruling[]>;
432
+ byId(id: string): Promise<Ruling[]>;
433
+ byMtgoId(id: number): Promise<Ruling[]>;
434
+ byMultiverseId(id: number): Promise<Ruling[]>;
435
+ bySet(set: string, collectorNumber: number | string): Promise<Ruling[]>;
436
+ }
437
+ declare const rulings: RulingApi;
438
+ declare class InvalidScryfallArgumentError extends Error {}
439
+ declare class ScryfallError extends Error {
440
+ readonly code: string;
441
+ readonly status: number;
442
+ readonly type?: null | string | undefined;
443
+ readonly warnings?: null | string[] | undefined;
444
+ constructor(code: string, details: string, status: number, type?: null | string | undefined, warnings?: null | string[] | undefined);
445
+ }
446
+ declare class UnknownScryfallError extends Error {}
447
+ export { type BorderColor, type Card, type CardComponent, type CardFace, type CardIdentifier, CardIdentifierApi as CardIdentifierBuilder, type CardIdentifierCollectorSet, type CardIdentifierId, type CardIdentifierIllustrationId, type CardIdentifierMtgGoId, type CardIdentifierMultiverseId, type CardIdentifierNameSet, type CardIdentifierOracleId, type CardLanguage, type CardLayout, type CardSearch, type CardSearchDirection, type CardSearchFormat, type CardSearchOrder, type CardSearchUnique, cards as Cards, catalog as Catalogs, type Color, type Finish, type Frame, type FrameEffect, type Game, type ImageStatus, type ImageUris, InvalidScryfallArgumentError, type Legalities, type Legality, MagicPageResult, type ManaCost, type Preview, type Prices, type PromoType, type PurchaseUris, type Rarity, type RelatedCard, type RelatedUris, rulings as Rulings, ScryfallError, type SecurityStamp, type Set, type SetType, set as Sets, type Symbology, symbology as SymbologyApi, UnknownScryfallError };