Git Product home page Git Product logo

scryfall's Introduction

Scryfall

This module wraps the Scryfall API into a small, easy to use library.

Included with this module are Typescript definitions for each method declaration and every object returned from the API.

Example usage

Finding a card:

// Requiring.
const scryfall = require("scryfall");
// Using the import statement.
import * as scryfall from "scryfall";
// Alternative import method.
import { Scryfall } from "scryfall";

// Getting by set code and collector number.
scryfall.getCard("bfz", 29, (err, card) => {
    if (err) {
        // If the call was successful, this will be null.
    } else {
        console.log(card.name); // "Gideon, Ally of Zendikar"
        console.log(card.cmc); // 4
        // ...
    }
});

// You can also omit a callback to have the method return a promise instead.
const card = await scryfall.getCard("bfz", 29);
console.log(card.name); // "Gideon, Ally of Zendikar"
console.log(card.cmc); // 4


// Getting by multiverse id.
scryfall.getCard(83282, "multiverse", (err, card) => {
    if (err) {
        // If the call was successful, this will be null.
    } else {
        console.log(card.name); // "Storm Crow"
        console.log(card.type_line); // "Creature โ€” Bird"
        // ...
    }
});

// Getting by mtgo id.
scryfall.getCard(83282, "mtgo", (err, card) => {
    if (err) {
        // If the call was successful, this will be null.
    } else {
        console.log(card.name); // "Gorilla Shaman"
        console.log(card.tix); // "12.62"
        // ...
    }
});

// Getting by scryfall id.
scryfall.getCard("44012bb8-17b7-4b50-a796-662ef09bfc29", (err, card) => {
    if (err) {
        // If the call was successful, this will be null.
    } else {
        console.log(card.name); // "Bamboozle"
        console.log(card.colors); // ["U"]
        // ...
    }
});

Finding cards from a particular set:

scryfall.fromSet("hml", (cards) => {
    console.log(cards[0].name); // "Abbey Gargoyles"
});

scryfall's People

Contributors

harubex 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.