Git Product home page Git Product logo

mtg-sdk-javascript's Introduction

Magic: The Gathering SDK

mtg-developers on discord Build Status

This is the Magic: The Gathering SDK Javascript implementation. It is a wrapper around the MTG API of magicthegathering.io.

Installation

npm install --save mtgsdk

Usage

const mtg = require('mtgsdk')

mtg.card.find(3)
.then(result => {
    console.log(result.card.name) // "Black Lotus"
})

mtg.set.find('AER')
.then(result => {
    console.log(result.set.name) // "Aether Revolt"
})

Query cards and sets by any property:

card.where({ supertypes: 'legendary', subtypes: 'goblin' })
.then(cards => {
    console.log(cards[0].name) // "Squee, Goblin Nabob"
})

set.where({ block: 'Shadows over Innistrad', border: 'black' })
.then(sets => {
  console.log(sets[0].name) // "Welcome Deck 2016"
  console.log(sets[1].name) // "Shadows over Innistrad"
  console.log(sets[2].name) // "Eldritch Moon"
})

Retrieve cards across multiple pages of results:

card.all({ name: 'Squee', pageSize: 1 })
.on('data', card => {
    console.log(card.name)
})

// Will print:
// Squee
// Squee, Goblin Nabob Avatar
// Squee's Toy
// Squeeze
// Squee, Goblin Nabob
// Squee's Embrace
// Squee's Revenge
// Squee, Goblin Nabob
// Squee, Goblin Nabob
// (the duplicates are from different sets)

set.all({ name: 'limited' })
.on('data', set => {
  console.log(set.name)
})

// Will print:
// Limited Edition Alpha
// Limited Edition Beta
// Unlimited Edition

Properties

Card

name
multiverseid
layout
names
manaCost
cmc
colors
type
types
subtypes
rarity
text
flavor
artist
number
power
toughness
reserved
rulings
printings
originalText
originalType
legalities
source
imageUrl
set
id

Set

code
name
gatherer_code
old_code
magic_cards_info_code
release_date
border
type
block
online_only
booster
mkm_id
mkm_name

Please note: Currently, sets are only queryable on their name and block fields.

Development

Build tasks are in npm scripts:

npm run

mtg-sdk-javascript's People

Contributors

raineorshine avatar dependabot[bot] avatar adback03 avatar bemacized avatar beauregardhenry avatar christian4423 avatar silviopilato avatar igogo5yo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.