scryfall-api 2.2.0 → 3.0.1
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/CHANGELOG.md +7 -34
- package/DOCUMENTATION.md +505 -0
- package/LICENSE +18 -4
- package/README.md +8 -14
- package/SUPPORT.md +38 -0
- package/dist/scryfall-api.cjs.d.ts +1 -0
- package/dist/scryfall-api.cjs.dev.js +712 -0
- package/dist/scryfall-api.cjs.js +7 -0
- package/dist/scryfall-api.cjs.prod.js +712 -0
- package/dist/scryfall-api.esm.js +697 -0
- package/dist/scryfall-api.umd.min.js +2 -0
- package/dist/scryfall-api.umd.min.js.map +1 -0
- package/package.json +36 -91
- package/lib/api/CardIdentifierBuilder.d.ts +0 -10
- package/lib/api/Cards.d.ts +0 -19
- package/lib/api/Cards.spec.d.ts +0 -1
- package/lib/api/Catalog.d.ts +0 -18
- package/lib/api/Catalog.spec.d.ts +0 -1
- package/lib/api/Misc.d.ts +0 -7
- package/lib/api/Misc.spec.d.ts +0 -1
- package/lib/api/Rulings.d.ts +0 -11
- package/lib/api/Rulings.spec.d.ts +0 -1
- package/lib/api/Sets.d.ts +0 -10
- package/lib/api/Sets.spec.d.ts +0 -1
- package/lib/api/Symbology.d.ts +0 -8
- package/lib/api/Symbology.spec.d.ts +0 -1
- package/lib/error/MagicQueryError.d.ts +0 -5
- package/lib/index.d.ts +0 -11
- package/lib/query/MagicPageResult.d.ts +0 -18
- package/lib/query/MagicQuery.d.ts +0 -13
- package/lib/skryfall.es5.js +0 -660
- package/lib/skryfall.es5.js.map +0 -1
- package/lib/skryfall.es5.min.js +0 -16
- package/lib/skryfall.es5.min.js.map +0 -1
- package/lib/skryfall.umd.js +0 -679
- package/lib/skryfall.umd.js.map +0 -1
- package/lib/skryfall.umd.min.js +0 -16
- package/lib/skryfall.umd.min.js.map +0 -1
- package/lib/types/Border.d.ts +0 -7
- package/lib/types/BulkDataDefinition.d.ts +0 -14
- package/lib/types/BulkDataType.d.ts +0 -2
- package/lib/types/BulkDataTypes.d.ts +0 -7
- package/lib/types/Card.d.ts +0 -91
- package/lib/types/CardFace.d.ts +0 -22
- package/lib/types/CardIdentifier.d.ts +0 -10
- package/lib/types/CardSymbol.d.ts +0 -13
- package/lib/types/Color.d.ts +0 -9
- package/lib/types/Format.d.ts +0 -15
- package/lib/types/FrameEffect.d.ts +0 -17
- package/lib/types/Game.d.ts +0 -5
- package/lib/types/HomepageLink.d.ts +0 -9
- package/lib/types/ImageUris.d.ts +0 -8
- package/lib/types/Layout.d.ts +0 -20
- package/lib/types/Legalties.d.ts +0 -5
- package/lib/types/Legalty.d.ts +0 -6
- package/lib/types/ManaCost.d.ts +0 -9
- package/lib/types/PageQuery.d.ts +0 -5
- package/lib/types/PageQueryValue.d.ts +0 -1
- package/lib/types/Preview.d.ts +0 -5
- package/lib/types/Prices.d.ts +0 -6
- package/lib/types/PromoType.d.ts +0 -27
- package/lib/types/PurchaseUris.d.ts +0 -6
- package/lib/types/Query.d.ts +0 -4
- package/lib/types/Rarity.d.ts +0 -6
- package/lib/types/RelatedCard.d.ts +0 -9
- package/lib/types/RelatedCardComponent.d.ts +0 -6
- package/lib/types/RelatedUris.d.ts +0 -7
- package/lib/types/ResultCatalog.d.ts +0 -2
- package/lib/types/ResultData.d.ts +0 -4
- package/lib/types/ResultList.d.ts +0 -7
- package/lib/types/RetryStrategy.d.ts +0 -11
- package/lib/types/Ruling.d.ts +0 -5
- package/lib/types/SearchError.d.ts +0 -7
- package/lib/types/SearchOptions.d.ts +0 -15
- package/lib/types/Set.d.ts +0 -20
- package/lib/types/SetType.d.ts +0 -22
- package/lib/types/Sort.d.ts +0 -15
- package/lib/types/SortDirection.d.ts +0 -5
- package/lib/types/TOrArrayOfT.d.ts +0 -1
- package/lib/types/UniqueStrategy.d.ts +0 -5
- package/lib/types/index.d.ts +0 -42
package/CHANGELOG.md
CHANGED
|
@@ -1,40 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# scryfall-api
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## 3.0.1
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- 30beaf5: Fixed readme in npm.js
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
## 3.0.0
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
### Major Changes
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
### Bug Fixes
|
|
16
|
-
|
|
17
|
-
* fixed index exports ([d0e8835](https://bitbucket.org/MarioMH/scryfall-api/commit/d0e8835b61467b8119b33fc3407f64ea3aa333d1))
|
|
18
|
-
|
|
19
|
-
### [2.1.3](https://bitbucket.org/MarioMH/scryfall-api/compare/v2.1.2...v2.1.3) (2021-10-18)
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### Bug Fixes
|
|
23
|
-
|
|
24
|
-
* fixed index exports ([5087d91](https://bitbucket.org/MarioMH/scryfall-api/commit/5087d91cd8129b572332aff73a6e24fe0bd5470b))
|
|
25
|
-
|
|
26
|
-
### [2.1.2](https://bitbucket.org/MarioMH/scryfall-api/compare/v2.1.1...v2.1.2) (2021-10-16)
|
|
27
|
-
|
|
28
|
-
### [2.1.1](https://bitbucket.org/MarioMH/scryfall-api/compare/v2.1.0...v2.1.1) (2021-10-16)
|
|
29
|
-
|
|
30
|
-
## 2.1.0 (2021-10-16)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
### Features
|
|
34
|
-
|
|
35
|
-
* removed BulkData ([110d6e2](https://bitbucket.org/MarioMH/scryfall-api/commit/110d6e27d6bdd98889e760d33c122713371b491d))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### Bug Fixes
|
|
39
|
-
|
|
40
|
-
* removed invalid condition ([c74c0c7](https://bitbucket.org/MarioMH/scryfall-api/commit/c74c0c793bf43058c7a705b043b3cfd661a35206))
|
|
13
|
+
- 91baaf8: Migrated repository to GitHub.
|
package/DOCUMENTATION.md
ADDED
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
## Table of Contents
|
|
2
|
+
|
|
3
|
+
- [Usage](#usage)
|
|
4
|
+
- [Cards](#cards)
|
|
5
|
+
- [`Cards.autoCompleteName(name: string): Promise<string[]>;` ](#cardsautocompletenamename-string-promisestring-)
|
|
6
|
+
- [`Cards.byArenaId(id: number): Promise<Card | undefined>;` ](#cardsbyarenaidid-number-promiscard-undefined-)
|
|
7
|
+
- [`Cards.byId(id: string): Promise<Card | undefined>;`](#cardsbyidid-string-promiscard-undefined-)
|
|
8
|
+
- [`Cards.byMtgoId(id: number): Promise<Card | undefined>;` ](#cardsbymtgoidid-number-promiscard-undefined-)
|
|
9
|
+
- [`Cards.byMultiverseId(id: number): Promise<Card | undefined>;` ](#cardsbymultiverseidid-number-promiscard-undefined-)
|
|
10
|
+
- [`Cards.byName(name: string, fuzzy = false): Promise<Card | undefined>;`](#cardsbynamename-string-set-string-fuzzy-false-promiscard-undefined-)
|
|
11
|
+
- [`Cards.byName(name: string, set?: string, fuzzy = false): Promise<Card | undefined>;`](#cardsbynamename-string-set-string-fuzzy-false-promiscard-undefined-)
|
|
12
|
+
- [`Cards.bySet(code: string, collectorId: number, lang?: string): Promise<Card | undefined>;`](#cardsbysetsetcode-string-collectornumber-number-lang-string-promiscard-undefined-)
|
|
13
|
+
- [`Cards.byTcgPlayerId(id: number): Promise<Card | undefined>;` ](#cardsbytcgplayeridid-number-promiscard-undefined-)
|
|
14
|
+
- [`Cards.collection(...collection: CardIdentifier[]): Promise<Card[]>;`](#cardscollectioncollection-cardidentifier-promiscard-)
|
|
15
|
+
- [`Cards.random(id: number): Promise<Card | undefined>;` ](#cardsrandomid-number-promiscard-undefined-)
|
|
16
|
+
- [`Cards.search(query: string, options?: SearchOptions | number): MagicPageResult<Card, Cards>;` ](#cardssearchquery-string-options-searchoptions-number-magicpageresultcard-cards-)
|
|
17
|
+
- [Sets](#sets)
|
|
18
|
+
- [`Sets.all(): Promise<Set[]>;` ](#setsall-promisset-)
|
|
19
|
+
- [`Sets.byCode(code: string): Promise<Set>;` ](#setsbycodecode-string-promisset-)
|
|
20
|
+
- [`Sets.byId(id: string): Promise<Set>;` ](#setsbyidid-string-promisset-)
|
|
21
|
+
- [`Sets.byTcgPlayerId(id: number): Promise<Set>;` ](#setsbytcgplayeridid-number-promisset-)
|
|
22
|
+
- [Rulings](#rulings)
|
|
23
|
+
- [`Rulings.byArenaId(id: number): Promise<Ruling[]>;` ](#rulingsbyarenaidid-number-promisruling-)
|
|
24
|
+
- [`Rulings.byId(id: string): Promise<Ruling[]>;` ](#rulingsbyidid-string-promisruling-)
|
|
25
|
+
- [`Rulings.byMtgoId(id: number): Promise<Ruling[]>;` ](#rulingsbymtgoidid-number-promisruling-)
|
|
26
|
+
- [`Rulings.byMultiverseId(id: number): Promise<Ruling[]>;` ](#rulingsbymultiverseidid-number-promisruling-)
|
|
27
|
+
- [`Rulings.bySet(code: string, collectorId: string | number): Promise<Ruling[]>;` ](#rulingsbysetcode-string-collectorid-string-number-promisruling-)
|
|
28
|
+
- [Symbology](#symbology)
|
|
29
|
+
- [`Symbology.all(): Promise<CardSymbol[]>;`](#symbologyall-promiscardsymbol-)
|
|
30
|
+
- [`Symbology.parseMana(mana: string): Promise<ManaCost>;` ](#symbologyparsemanamana-string-promismanacost-)
|
|
31
|
+
- [Catalogs](#catalogs)
|
|
32
|
+
- [`Catalog.artifactTypes(): Promise<string[]>;` ](#catalogartifacttypes-promisstring-)
|
|
33
|
+
- [`Catalog.artistNames(): Promise<string[]>;` ](#catalogartistnames-promisstring-)
|
|
34
|
+
- [`Catalog.cardNames(): Promise<string[]>;` ](#catalogcardnames-promisstring-)
|
|
35
|
+
- [`Catalog.creatureTypes(): Promise<string[]>;` ](#catalogcreaturetypes-promisstring-)
|
|
36
|
+
- [`Catalog.enchantmentTypes(): Promise<string[]>;` ](#catalogenchantmenttypes-promisstring-)
|
|
37
|
+
- [`Catalog.landTypes(): Promise<string[]>;`](#cataloglandtypes-promisstring-)
|
|
38
|
+
- [`Catalog.loyalties(): Promise<string[]>;` ](#catalogloyalties-promisstring-)
|
|
39
|
+
- [`Catalog.planeswalkerTypes(): Promise<string[]>;` ](#catalogplaneswalkertypes-promisstring-)
|
|
40
|
+
- [`Catalog.powers(): Promise<string[]>;` ](#catalogpowers-promisstring-)
|
|
41
|
+
- [`Catalog.spellTypes(): Promise<string[]>;` ](#catalogspelltypes-promisstring-)
|
|
42
|
+
- [`Catalog.toughnesses(): Promise<string[]>;`](#catalooughnesses-promisstring-)
|
|
43
|
+
- [`Catalog.watermarks(): Promise<string[]>;` ](#catalogwatermarks-promisstring-)
|
|
44
|
+
- [`Catalog.wordBank(): Promise<string[]>;`](#catalogwordbank-promisstring-)
|
|
45
|
+
- [Misc](#misc)
|
|
46
|
+
- [`Misc.homepageLinks(): Promise<string[]>;`](#mischomepagelinks-promisstring)
|
|
47
|
+
|
|
48
|
+
## Usage [↑](#table-of-contents)
|
|
49
|
+
|
|
50
|
+
In the documentation below, requiring the package is assumed.
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
const Scry = require('scryfall-api');
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or with TypeScrypt:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
import * as Scry from 'scryfall-api';
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
If you only need Cards
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { Cards } from 'scryfall-api';
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Cards [↑](#table-of-contents)
|
|
69
|
+
|
|
70
|
+
### `Cards.autoCompleteName(name: string): Promise<string[]>;` [↑](#table-of-contents)
|
|
71
|
+
|
|
72
|
+
From the [Scryfall documentation](https://scryfall.com/docs/api/cards/autocomplete):
|
|
73
|
+
|
|
74
|
+
Returns [an array] containing up to 25 full card names that could be autocompletions of the given string parameter q.
|
|
75
|
+
|
|
76
|
+
This method is designed for creating assistive UI elements that allow users to free-type card names.
|
|
77
|
+
The names are sorted with the nearest match first.
|
|
78
|
+
|
|
79
|
+
Spaces, punctuation, and capitalization are ignored.
|
|
80
|
+
|
|
81
|
+
If q is less than 2 characters long, or if no names match, the Catalog will contain 0 items(instead of returning any errors).
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { Cards } from 'scryfall-api';
|
|
85
|
+
|
|
86
|
+
Cards.autoCompleteName('bloodsc').then(results => {
|
|
87
|
+
for (const result of results) {
|
|
88
|
+
console.log(result);
|
|
89
|
+
// Bloodscent
|
|
90
|
+
// Blood Scrivener
|
|
91
|
+
// Bloodscale Prowler
|
|
92
|
+
// Burning-Tree Bloodscale
|
|
93
|
+
// Ghor-Clan Bloodscale
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### `Cards.byArenaId(id: number): Promise<Card | undefined>;` [↑](#table-of-contents)
|
|
99
|
+
|
|
100
|
+
Gets a card based on its MTG Arena id.
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
import { Cards } from 'scryfall-api';
|
|
104
|
+
|
|
105
|
+
Cards.byArenaId(67330).then(result => console.log(result.name)); // Yargle, Glutton of Urborg
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### `Cards.byId(id: string): Promise<Card | undefined>;` [↑](#table-of-contents)
|
|
109
|
+
|
|
110
|
+
Gets a single card from its ID.
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { Cards } from 'scryfall-api';
|
|
114
|
+
|
|
115
|
+
Cards.byId('9ea8179a-d3c9-4cdc-a5b5-68cc73279050').then(result => console.log(result.name)); // Blood Scrivener
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `Cards.byMtgoId(id: number): Promise<Card | undefined>;` [↑](#table-of-contents)
|
|
119
|
+
|
|
120
|
+
Gets a card based on its MTGO(sometimes called "Cat") id.
|
|
121
|
+
|
|
122
|
+
```ts
|
|
123
|
+
import { Cards } from 'scryfall-api';
|
|
124
|
+
|
|
125
|
+
Cards.byMtgoId(48338).then(result => console.log(result.name)); // Blood Scrivener
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `Cards.byMultiverseId(id: number): Promise<Card | undefined>;` [↑](#table-of-contents)
|
|
129
|
+
|
|
130
|
+
Gets a card based on its multiverse id.
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
Cards.byMultiverseId(369030).then(result => console.log(result.name)); // Blood Scrivener
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### `Cards.byName(name: string, set?: string, fuzzy = false): Promise<Card | undefined>;` [↑](#table-of-contents)
|
|
137
|
+
|
|
138
|
+
Gets a card based on its name. Supports fuzzy searching, by 1-2 replacements/translations.
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
import { Cards } from 'scryfall-api';
|
|
142
|
+
|
|
143
|
+
Cards.byName('Blood Scrivener').then(result => console.log(result.name)); // Blood Scrivener
|
|
144
|
+
Cards.byName('Bliid Scrivener', true).then(result => console.log(result.name)); // Blood Scrivener
|
|
145
|
+
Cards.byName('Loxodon Warhammer', 'MRD').then(result => console.log(result.name, result.set)); // Loxodon Warhammer, mrd
|
|
146
|
+
Cards.byName('Warhammer', 'MRD', true).then(result => console.log(result.name, result.set)); // Loxodon Warhammer, mrd
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### `Cards.bySet(setCode: string, collectorNumber: number, lang?: string): Promise<Card | undefined>;` [↑](#table-of-contents)
|
|
150
|
+
|
|
151
|
+
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](https://scryfall.com/docs/api/languages).
|
|
152
|
+
|
|
153
|
+
```ts
|
|
154
|
+
import { Cards } from 'scryfall-api';
|
|
155
|
+
|
|
156
|
+
Cards.bySet('dgm', 22).then(result => console.log(result.name + ', ' + result.printed_name)); // Blood Scrivener, undefined
|
|
157
|
+
Cards.bySet('dgm', 22, 'ja').then(result => console.log(result.name + ', ' + result.printed_name)); // Blood Scrivener, 血の公証人
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### `Cards.byTcgPlayerId(id: number): Promise<Card | undefined>;` [↑](#table-of-contents)
|
|
161
|
+
|
|
162
|
+
Gets a card based on its TCG Player id.
|
|
163
|
+
|
|
164
|
+
```ts
|
|
165
|
+
import { Cards } from 'scryfall-api';
|
|
166
|
+
|
|
167
|
+
Cards.byTcgPlayerId(1030).then(result => console.log(result.name)); // Ankh of Mishra
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### `Cards.collection(...collection: CardIdentifier[]): Promise<Card[]>;` [↑](#table-of-contents)
|
|
171
|
+
|
|
172
|
+
Takes a list of "card identifiers", which describe a card, and returns their actual card objects.
|
|
173
|
+
|
|
174
|
+
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_.
|
|
175
|
+
|
|
176
|
+
In order to assist with manual requests, this method comes with a new set of factories by the name `CardIdentifier`. These are:
|
|
177
|
+
|
|
178
|
+
- `CardIdentifier.byId(id: string): CardIdentifier;`
|
|
179
|
+
- `CardIdentifier.byMultiverseId(id: number): CardIdentifier;`
|
|
180
|
+
- `CardIdentifier.byMtgoId(id: number): CardIdentifier;`
|
|
181
|
+
- `CardIdentifier.byOracleId(id: string): CardIdentifier;`
|
|
182
|
+
- `CardIdentifier.byIllustrationId(id: string): CardIdentifier;`
|
|
183
|
+
- `CardIdentifier.byName(string: string, set?: string): CardIdentifier;`
|
|
184
|
+
- `CardIdentifier.byName(string: string, set?: string): CardIdentifier;`
|
|
185
|
+
- `CardIdentifier.bySet(set: string, collectorNumber: string | number): CardIdentifier;`
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
import { Cards, CardIdentifier } from 'scryfall-api';
|
|
189
|
+
|
|
190
|
+
const collection = [
|
|
191
|
+
CardIdentifier.byId('94c70f23-0ca9-425e-a53a-6c09921c0075'),
|
|
192
|
+
CardIdentifier.byMultiverseId(462293),
|
|
193
|
+
CardIdentifier.byMtgoId(71692),
|
|
194
|
+
CardIdentifier.byOracleId('394c6de5-7957-4a0b-a6b9-ee0c707cd022'),
|
|
195
|
+
CardIdentifier.byIllustrationId('99f43949-049e-41e2-bf4c-e22e11790012'),
|
|
196
|
+
CardIdentifier.byName('Blood Scrivener'),
|
|
197
|
+
CardIdentifier.byName('Lightning Bolt', 'prm'),
|
|
198
|
+
CardIdentifier.bySet('mrd', '150'),
|
|
199
|
+
];
|
|
200
|
+
|
|
201
|
+
const cards = await Cards.collection(...collection);
|
|
202
|
+
// every card identifier has been mapped to its real card object
|
|
203
|
+
|
|
204
|
+
for (const card of cards) {
|
|
205
|
+
console.log(card.name);
|
|
206
|
+
}
|
|
207
|
+
// Crush Dissent
|
|
208
|
+
// Contentious Plan
|
|
209
|
+
// Bond of Insight
|
|
210
|
+
// Forgotten Cave
|
|
211
|
+
// GO TO JAIL
|
|
212
|
+
// Blood Scrivener
|
|
213
|
+
// Lightning Bolt
|
|
214
|
+
// Chalice of the Void
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### `Cards.random(id: number): Promise<Card | undefined>;` [↑](#table-of-contents)
|
|
218
|
+
|
|
219
|
+
Gets a random card.
|
|
220
|
+
|
|
221
|
+
```ts
|
|
222
|
+
import { Cards } from 'scryfall-api';
|
|
223
|
+
|
|
224
|
+
Cards.random().then(result => console.log(result.name));
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### `Cards.search(query: string, options?: SearchOptions | number): MagicPageResult<Card, Cards>;` [↑](#table-of-contents)
|
|
228
|
+
|
|
229
|
+
Queries for a card using the [Scryfall Search API](https://scryfall.com/docs/reference).
|
|
230
|
+
|
|
231
|
+
```ts
|
|
232
|
+
import { Cards } from 'scryfall-api';
|
|
233
|
+
|
|
234
|
+
Cards.search('type:planeswalker')
|
|
235
|
+
.all()
|
|
236
|
+
.then(result => console.log(result.name));
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
For information on how to provide extra options, see the [`/get/cards/search`](https://scryfall.com/docs/api/cards/search) page on Scryfall. You can also reference the [`SearchOptions`](src/types/SearchOptions.ts) interface
|
|
240
|
+
|
|
241
|
+
This query returns a [`MagicPageResult`](#magicemittert-).
|
|
242
|
+
|
|
243
|
+
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:
|
|
244
|
+
|
|
245
|
+
```ts
|
|
246
|
+
import { Cards } from 'scryfall-api';
|
|
247
|
+
|
|
248
|
+
// Start in page 13
|
|
249
|
+
const result = Cards.search('type:planeswalker', 13);
|
|
250
|
+
|
|
251
|
+
// Get page 13
|
|
252
|
+
const cardsFromPage13 = await result.next(); // cardsFromPage13.lenth === 175
|
|
253
|
+
|
|
254
|
+
// Get page 14
|
|
255
|
+
const cardsFromPage14 = await result.next(); // cardsFromPage14.lenth === 175
|
|
256
|
+
|
|
257
|
+
// Or you can get any page directly by
|
|
258
|
+
const cardsFromPage15 = await result.page(15); // cardsFromPage15.lenth === 175
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
You can bypass the 175 card limit by using:
|
|
262
|
+
|
|
263
|
+
```ts
|
|
264
|
+
import { Cards } from 'scryfall-api';
|
|
265
|
+
|
|
266
|
+
// Get 300 cards starting on page 1
|
|
267
|
+
const result1 = await Cards.search('type:planeswalker').get(200); // result.lenth === 200
|
|
268
|
+
|
|
269
|
+
// Get 300 cards starting on page 13
|
|
270
|
+
const result2 = await Cards.search('type:planeswalker', 13).get(300); // result.lenth === 300
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
## Sets [↑](#table-of-contents)
|
|
274
|
+
|
|
275
|
+
### `Sets.all(): Promise<Set[]>;` [↑](#table-of-contents)
|
|
276
|
+
|
|
277
|
+
Gets all sets.
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
import { Sets } from 'scryfall-api';
|
|
281
|
+
|
|
282
|
+
Sets.all().then(result => console.log(result.lenh));
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### `Sets.byCode(code: string): Promise<Set>;` [↑](#table-of-contents)
|
|
286
|
+
|
|
287
|
+
Gets a set by its code.
|
|
288
|
+
|
|
289
|
+
```ts
|
|
290
|
+
import { Sets } from 'scryfall-api';
|
|
291
|
+
|
|
292
|
+
Sets.byCode('hou').then(set => console.log(set.name)); // Hour of Devastation
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### `Sets.byId(id: string): Promise<Set>;` [↑](#table-of-contents)
|
|
296
|
+
|
|
297
|
+
Gets a set by its Scryfall ID.
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
import { Sets } from 'scryfall-api';
|
|
301
|
+
|
|
302
|
+
Sets.byId('65ff168b-bb94-47a5-a8f9-4ec6c213e768').then(set => console.log(set.name)); // Hour of Devastation
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### `Sets.byTcgPlayerId(id: number): Promise<Set>;` [↑](#table-of-contents)
|
|
306
|
+
|
|
307
|
+
Gets a set by its TCG Player ID, also known as the `groupId` on [TCGPlayer's API](https://docs.tcgplayer.com/docs).
|
|
308
|
+
|
|
309
|
+
```ts
|
|
310
|
+
import { Sets } from 'scryfall-api';
|
|
311
|
+
|
|
312
|
+
Sets.byTcgPlayerId(1934).then(set => console.log(set.name)); // Hour of Devastation
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
## Rulings [↑](#table-of-contents)
|
|
316
|
+
|
|
317
|
+
### `Rulings.byArenaId(id: number): Promise<Ruling[]>;` [↑](#table-of-contents)
|
|
318
|
+
|
|
319
|
+
Gets the rulings for a card based on its Arena id.
|
|
320
|
+
|
|
321
|
+
```ts
|
|
322
|
+
import { Rulings } from 'scryfall-api';
|
|
323
|
+
|
|
324
|
+
Rulings.byArenaId(67204).then(result => console.log(result.lenh)); // 3
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### `Rulings.byId(id: string): Promise<Ruling[]>;` [↑](#table-of-contents)
|
|
328
|
+
|
|
329
|
+
Gets the rulings for a single card from its ID.
|
|
330
|
+
|
|
331
|
+
```ts
|
|
332
|
+
import { Rulings } from 'scryfall-api';
|
|
333
|
+
|
|
334
|
+
Rulings.byId('9ea8179a-d3c9-4cdc-a5b5-68cc73279050').then(result => console.log(result.lenh)); // 2
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### `Rulings.byMtgoId(id: number): Promise<Ruling[]>;` [↑](#table-of-contents)
|
|
338
|
+
|
|
339
|
+
Gets the rulings for a card based on its MTGO(sometimes called "Cat") id.
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
import { Rulings } from 'scryfall-api';
|
|
343
|
+
|
|
344
|
+
Rulings.byMtgoId(48338).then(result => console.log(result.lenh)); // 2
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### `Rulings.byMultiverseId(id: number): Promise<Ruling[]>;` [↑](#table-of-contents)
|
|
348
|
+
|
|
349
|
+
Gets the rulings for a card based on its multiverse id.
|
|
350
|
+
|
|
351
|
+
```ts
|
|
352
|
+
import { Rulings } from 'scryfall-api';
|
|
353
|
+
|
|
354
|
+
Rulings.byMultiverseId(369030).then(result => console.log(result.lenh)); // 2
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
### `Rulings.bySet(code: string, collectorId: string | number): Promise<Ruling[]>;` [↑](#table-of-contents)
|
|
358
|
+
|
|
359
|
+
Gets the rulings for a card based on its set and collector id.
|
|
360
|
+
|
|
361
|
+
```ts
|
|
362
|
+
import { Rulings } from 'scryfall-api';
|
|
363
|
+
|
|
364
|
+
Rulings.bySet('dgm', '22').then(result => console.log(result.lenh)); // 2
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
## Symbology [↑](#table-of-contents)
|
|
368
|
+
|
|
369
|
+
### `Symbology.all(): Promise<CardSymbol[]>;` [↑](#table-of-contents)
|
|
370
|
+
|
|
371
|
+
Gets all [card symbols](https://scryfall.com/docs/api/card-symbols).
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
import { Symbology } from 'scryfall-api';
|
|
375
|
+
|
|
376
|
+
Symbology.all().then(result => console.log(result.lenh)); // 63
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
### `Symbology.parseMana(mana: string): Promise<ManaCost>;` [↑](#table-of-contents)
|
|
380
|
+
|
|
381
|
+
From the [Scryfall documentation](https://scryfall.com/docs/api/card-symbols/parse-mana):
|
|
382
|
+
|
|
383
|
+
Parses the given mana cost parameter and returns Scryfall’s interpretation.
|
|
384
|
+
|
|
385
|
+
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}`).
|
|
386
|
+
|
|
387
|
+
```ts
|
|
388
|
+
import { Symbology } from 'scryfall-api';
|
|
389
|
+
|
|
390
|
+
Symbology.parseMana('7wg').then(result => console.log(result.cost)); // {7}{W}{G}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
## Catalogs [↑](#table-of-contents)
|
|
394
|
+
|
|
395
|
+
### `Catalog.cardNames(): Promise<string[]>;` [↑](#table-of-contents)
|
|
396
|
+
|
|
397
|
+
```ts
|
|
398
|
+
import { Catalog } from 'scryfall-api';
|
|
399
|
+
|
|
400
|
+
Catalog.cardNames().then(result => console.log(result.lenh)); // 18059
|
|
401
|
+
```
|
|
402
|
+
|
|
403
|
+
### `Catalog.artistNames(): Promise<string[]>;` [↑](#table-of-contents)
|
|
404
|
+
|
|
405
|
+
```ts
|
|
406
|
+
import { Catalog } from 'scryfall-api';
|
|
407
|
+
|
|
408
|
+
Catalog.artistNames().then(result => console.log(result.lenh)); // 676
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
### `Catalog.wordBank(): Promise<string[]>;` [↑](#table-of-contents)
|
|
412
|
+
|
|
413
|
+
```ts
|
|
414
|
+
import { Catalog } from 'scryfall-api';
|
|
415
|
+
|
|
416
|
+
Catalog.wordBank().then(result => console.log(result.lenh)); // 12892
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### `Catalog.creatureTypes(): Promise<string[]>;` [↑](#table-of-contents)
|
|
420
|
+
|
|
421
|
+
```ts
|
|
422
|
+
import { Catalog } from 'scryfall-api';
|
|
423
|
+
|
|
424
|
+
Catalog.creatureTypes().then(result => console.log(result.lenh)); // 242
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### `Catalog.planeswalkerTypes(): Promise<string[]>;` [↑](#table-of-contents)
|
|
428
|
+
|
|
429
|
+
```ts
|
|
430
|
+
import { Catalog } from 'scryfall-api';
|
|
431
|
+
|
|
432
|
+
Catalog.planeswalkerTypes().then(result => console.log(result.lenh)); // 42
|
|
433
|
+
```
|
|
434
|
+
|
|
435
|
+
### `Catalog.landTypes(): Promise<string[]>;` [↑](#table-of-contents)
|
|
436
|
+
|
|
437
|
+
```ts
|
|
438
|
+
import { Catalog } from 'scryfall-api';
|
|
439
|
+
|
|
440
|
+
Catalog.landTypes().then(result => console.log(result.lenh)); // 13
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### `Catalog.artifactTypes(): Promise<string[]>;` [↑](#table-of-contents)
|
|
444
|
+
|
|
445
|
+
```ts
|
|
446
|
+
import { Catalog } from 'scryfall-api';
|
|
447
|
+
|
|
448
|
+
Catalog.artifactTypes().then(result => console.log(result.lenh)); // 6
|
|
449
|
+
```
|
|
450
|
+
|
|
451
|
+
### `Catalog.enchantmentTypes(): Promise<string[]>;` [↑](#table-of-contents)
|
|
452
|
+
|
|
453
|
+
```ts
|
|
454
|
+
import { Catalog } from 'scryfall-api';
|
|
455
|
+
|
|
456
|
+
Catalog.enchantmentTypes().then(result => console.log(result.lenh)); // 5
|
|
457
|
+
```
|
|
458
|
+
|
|
459
|
+
### `Catalog.spellTypes(): Promise<string[]>;` [↑](#table-of-contents)
|
|
460
|
+
|
|
461
|
+
```ts
|
|
462
|
+
import { Catalog } from 'scryfall-api';
|
|
463
|
+
|
|
464
|
+
Catalog.spellTypes().then(result => console.log(result.lenh)); // 2
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### `Catalog.powers(): Promise<string[]>;` [↑](#table-of-contents)
|
|
468
|
+
|
|
469
|
+
```ts
|
|
470
|
+
import { Catalog } from 'scryfall-api';
|
|
471
|
+
|
|
472
|
+
Catalog.powers().then(result => console.log(result.lenh)); // 33
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### `Catalog.toughnesses(): Promise<string[]>;` [↑](#table-of-contents)
|
|
476
|
+
|
|
477
|
+
```ts
|
|
478
|
+
import { Catalog } from 'scryfall-api';
|
|
479
|
+
|
|
480
|
+
Catalog.toughnesses().then(result => console.log(result.lenh)); // 35
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### `Catalog.loyalties(): Promise<string[]>;` [↑](#table-of-contents)
|
|
484
|
+
|
|
485
|
+
```ts
|
|
486
|
+
import { Catalog } from 'scryfall-api';
|
|
487
|
+
|
|
488
|
+
Catalog.loyalties().then(result => console.log(result.lenh)); // 9
|
|
489
|
+
```
|
|
490
|
+
|
|
491
|
+
### `Catalog.watermarks(): Promise<string[]>;` [↑](#table-of-contents)
|
|
492
|
+
|
|
493
|
+
```ts
|
|
494
|
+
import { Catalog } from 'scryfall-api';
|
|
495
|
+
|
|
496
|
+
Catalog.watermarks().then(result => console.log(result.lenh)); // 50
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
## Misc [↑](#table-of-contents)
|
|
500
|
+
|
|
501
|
+
### `Misc.homepageLinks(): Promise<string[]>;` [↑](#table-of-contents)
|
|
502
|
+
|
|
503
|
+
```ts
|
|
504
|
+
Misc.homepageLinks().then(result => console.log(result.lenh)); // 4
|
|
505
|
+
```
|
package/LICENSE
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Copyright (c) 2021-2022 Mario Menéndez
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
6
11
|
|
|
7
|
-
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# scryfall-api
|
|
2
2
|
|
|
3
|
-
[](https://www.npmjs.com/package/scryfall-api)
|
|
4
|
+
[](https://github.com/MarioMH8/scryfall-api)
|
|
5
5
|
|
|
6
|
-
A
|
|
6
|
+
A Javascript library for [Scryfall](https://scryfall.com/docs/api) written in Typescript.
|
|
7
7
|
|
|
8
|
-
As of [
|
|
8
|
+
As of [January 29th, 2022](./CHANGELOG.md), almost all features described in the [Scryfall documentation](https://scryfall.com/docs/api) are supported. If you see something that isn't supported, make an issue! See [support readme](./SUPPORT.md).
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -22,9 +22,9 @@ Link to [documentation.](./DOCUMENTATION.md)
|
|
|
22
22
|
Thanks for wanting to help out! Here's the setup you'll have to do:
|
|
23
23
|
|
|
24
24
|
```bat
|
|
25
|
-
git clone
|
|
25
|
+
git clone git@github.com:MarioMH8/scryfall-api.git
|
|
26
26
|
cd scryfall-api
|
|
27
|
-
|
|
27
|
+
yarn install
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
You can now make changes to the repository.
|
|
@@ -32,15 +32,9 @@ You can now make changes to the repository.
|
|
|
32
32
|
To compile:
|
|
33
33
|
|
|
34
34
|
```bat
|
|
35
|
-
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
To compile on every file change:
|
|
39
|
-
|
|
40
|
-
```bat
|
|
41
|
-
npm run build:watch
|
|
35
|
+
yarn build
|
|
42
36
|
```
|
|
43
37
|
|
|
44
38
|
## MIT License
|
|
45
39
|
|
|
46
|
-
[Copyright
|
|
40
|
+
[Copyright 2021-2022 Mario Menéndez](./LICENSE)
|
package/SUPPORT.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
## Supported:
|
|
2
|
+
|
|
3
|
+
| Query | Result |
|
|
4
|
+
| --------------------------------------------------------------------------------------------------------------------------------- | ------------------ |
|
|
5
|
+
| [`/cards/named?{fuzzy/exact}=<card name>`](DOCUMENTATION.md#cardsbyname-name-string-fuzzy--false-promisecard-) | Card |
|
|
6
|
+
| [`/cards/:id`](DOCUMENTATION.md#cardsbyid-id-string-promisecard-) | Card |
|
|
7
|
+
| [`/cards/:set/:collector_number(/:lang)`](DOCUMENTATION.md#cardsbyset-setcode-string-collectorid-number-lang-string-promisecard-) | Card |
|
|
8
|
+
| [`/cards/multiverse/:multiverse_id`](DOCUMENTATION.mdardsbymultiverseid-id-number-promisecard-) | Card |
|
|
9
|
+
| [`/cards/mtgo/:mtgo_id`](DOCUMENTATION.mdardsbymtgoid-id-number-promisecard-) | Card |
|
|
10
|
+
| [`/cards/arena/:id`](DOCUMENTATION.mdardsbyarenaid-id-number-promisecard-) | Card |
|
|
11
|
+
| [`/cards/tcgplayer/:id`](DOCUMENTATION.mdardsbytcgplayerid-id-number-promisecard-) | Card |
|
|
12
|
+
| [`/cards/random`](DOCUMENTATION.mdardsrandom-id-number-promisecard-) | Card |
|
|
13
|
+
| [`/cards/search?q=:query`](DOCUMENTATION.mdardssearch-query-string-magicemittercard-) | List\<Card\> |
|
|
14
|
+
| [`/cards/autocomplete?q=:query`](DOCUMENTATION.mdardsautocompletename-name-string-promisestring-) | Catalog |
|
|
15
|
+
| [`/cards/collection`](DOCUMENTATION.mdardscollection-collection-cardidentifier-magicemittercard-) | List\<Card\> |
|
|
16
|
+
| [`/sets`](DOCUMENTATION.mdetsall--promiseset-) | List\<Set\> |
|
|
17
|
+
| [`/sets/:code`](DOCUMENTATION.mdetsbycode-code-string-promiseset-) | Set |
|
|
18
|
+
| [`/sets/:id`](DOCUMENTATION.mdetsbyid-id-string-promiseset-) | Set |
|
|
19
|
+
| [`/sets/tcgplayer/:id`](DOCUMENTATION.mdetsbytcgplayerid-id-number-promiseset-) | Set |
|
|
20
|
+
| [`/cards/multiverse/:id/rulings`](DOCUMENTATION.mdulingsbymultiverseid-id-number-promiseruling-) | List\<Ruling\> |
|
|
21
|
+
| [`/cards/mtgo/:id/rulings`](DOCUMENTATION.mdulingsbymtgoid-id-number-promiseruling-) | List\<Ruling\> |
|
|
22
|
+
| [`/cards/arena/:id/rulings`](DOCUMENTATION.mdulingsbyarenaid-id-number-promiseruling-) | List\<Ruling\> |
|
|
23
|
+
| [`/cards/:code/:number/rulings`](DOCUMENTATION.mdulingsbyset-code-string-collectorid-string-promiseruling-) | List\<Ruling\> |
|
|
24
|
+
| [`/cards/:id/rulings`](DOCUMENTATION.mdulingsbyid-id-string-promiseruling-) | List\<Ruling\> |
|
|
25
|
+
| [`/symbology`](DOCUMENTATION.mdymbologyall--promisecardsymbol-) | List\<CardSymbol\> |
|
|
26
|
+
| [`/symbology/parse-mana?cost=:cost`](DOCUMENTATION.mdymbologyparsemana-mana-string-promisemanacost-) | ManaCost |
|
|
27
|
+
| [`/catalog/card-names`](DOCUMENTATION.mdatalogcardnames--promisestring-) | Catalog |
|
|
28
|
+
| [`/catalog/word-bank`](DOCUMENTATION.mdatalogwordbank--promisestring-) | Catalog |
|
|
29
|
+
| [`/catalog/creature-types`](DOCUMENTATION.mdatalogcreaturetypes--promisestring-) | Catalog |
|
|
30
|
+
| [`/catalog/planeswalker-types`](DOCUMENTATION.mdatalogplaneswalkertypes--promisestring-) | Catalog |
|
|
31
|
+
| [`/catalog/land-types`](DOCUMENTATION.mdataloglandtypes--promisestring-) | Catalog |
|
|
32
|
+
| [`/catalog/artifact-types`](DOCUMENTATION.mdatalogartifacttypes--promisestring-) | Catalog |
|
|
33
|
+
| [`/catalog/enchantment-types`](DOCUMENTATION.mdatalogenchantmenttypes--promisestring-) | Catalog |
|
|
34
|
+
| [`/catalog/spell-types`](DOCUMENTATION.mdatalogspelltypes--promisestring-) | Catalog |
|
|
35
|
+
| [`/catalog/powers`](DOCUMENTATION.mdatalogpowers--promisestring-) | Catalog |
|
|
36
|
+
| [`/catalog/toughnesses`](DOCUMENTATION.mdatalogtoughnesses--promisestring-) | Catalog |
|
|
37
|
+
| [`/catalog/loyalties`](DOCUMENTATION.mdatalogloyalties--promisestring-) | Catalog |
|
|
38
|
+
| [`/catalog/watermarks`](DOCUMENTATION.mdatalogwatermarks--promisestring-) | Catalog |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./declarations/src/index";
|