11# Magic: The Gathering SDK
22
3- [ ![ mtg-developers on discord ] ( https://img.shields.io/badge/discord-mtg%20developers-738bd7.svg )] ( https://discord.gg/qwGJNnP )
4- [ ![ Build Status ] ( https://travis-ci.org/MagicTheGathering/ mtg-sdk-javascript .svg?branch=master )] ( https://travis-ci.org/MagicTheGathering/mtg-sdk-javascript )
3+ [ ![ npm version ] ( https://img.shields.io/npm/v/mtgsdk )] ( https://www.npmjs.com/package/mtgsdk )
4+ [ ![ discord ] ( https://img.shields.io/badge/discord- mtg%20developers-738bd7 .svg )] ( https://discord.gg/qwGJNnP )
55
66This is the Magic: The Gathering SDK Javascript implementation. It is a wrapper around the MTG API of [ magicthegathering.io] ( http://magicthegathering.io/ ) .
77
88## Installation
99
10- npm install --save mtgsdk
10+ ```
11+ npm install mtgsdk
12+ ```
1113
1214## Usage
13- ``` javascript
15+ ``` js
1416const mtg = require (' mtgsdk' )
1517
16- mtg .card .find (3 )
17- .then (result => {
18- console .log (result .card .name ) // "Black Lotus"
19- })
18+ const result = await mtg .card .find (3 )
19+ console .log (result .card .name ) // "Black Lotus"
2020
21- mtg .set .find (' AER' )
22- .then (result => {
23- console .log (result .set .name ) // "Aether Revolt"
24- })
21+ const result = await mtg .set .find (' AER' )
22+ console .log (result .set .name ) // "Aether Revolt"
2523```
2624
2725Query cards and sets by any property:
2826
29- ``` javascript
30- card .where ({ supertypes: ' legendary' , subtypes: ' goblin' })
31- .then (cards => {
32- console .log (cards[0 ].name ) // "Squee, Goblin Nabob"
33- })
27+ ``` js
28+ const result = await card .where ({ supertypes: ' legendary' , subtypes: ' goblin' })
29+ console .log (cards[0 ].name ) // "Squee, Goblin Nabob"
3430
35- set .where ({ block: ' Shadows over Innistrad' , border: ' black' })
36- .then (sets => {
37- console .log (sets[0 ].name ) // "Welcome Deck 2016"
38- console .log (sets[1 ].name ) // "Shadows over Innistrad"
39- console .log (sets[2 ].name ) // "Eldritch Moon"
40- })
31+ const result = await set .where ({ block: ' Shadows over Innistrad' , border: ' black' })
32+ console .log (sets[0 ].name ) // "Welcome Deck 2016"
33+ console .log (sets[1 ].name ) // "Shadows over Innistrad"
34+ console .log (sets[2 ].name ) // "Eldritch Moon"
4135```
4236
4337Retrieve cards across multiple pages of results:
4438
45- ``` javascript
39+ ``` js
4640card .all ({ name: ' Squee' , pageSize: 1 })
4741.on (' data' , card => {
4842 console .log (card .name )
4943})
5044
51- // Will print:
5245// Squee
5346// Squee, Goblin Nabob Avatar
5447// Squee's Toy
@@ -65,7 +58,6 @@ set.all({ name: 'limited' })
6558 console .log (set .name )
6659})
6760
68- // Will print:
6961// Limited Edition Alpha
7062// Limited Edition Beta
7163// Unlimited Edition
@@ -120,13 +112,3 @@ set.all({ name: 'limited' })
120112 mkm_name
121113
122114** Please note:** Currently, sets are only queryable on their _ name_ and _ block_ fields.
123-
124- ### Development
125-
126- - es6 ([ babel] ( https://babeljs.io ) )
127- - [ standardjs] ( http://standardjs.com )
128- - [ promises] ( https://www.promisejs.org )
129-
130- Build tasks are in npm scripts:
131-
132- npm run
0 commit comments