Coder Social home page Coder Social logo

tutor's Introduction

Tutor

Gatherer is the canonical source for Magic: The Gathering card details. While useful, it lacks an interface for retrieving this data programmatically. The lack of an API makes creating Magic-related applications unnecessarily difficult.

Tutor provides an API for Gatherer. It's a lightweight Express app that reads data from Gatherer and returns neatly formatted JSON.

Starting the app

To run the server:

$ npm install
$ coffee server

This starts a server listening on the port set as the environment variable PORT, or on port 3000 if PORT is undefined.

GET /card/:id

Returns a JSON representation of the card specified (by Gatherer id) in the request path. The response includes version-specific metadata such as flavor text and rarity.

JSON response

Flame Javelin

GET /card/:id/:part

Returns a JSON representation of the specified part of the specified multipart card. For example, GET /card/27166/Ice returns the Ice half of Fire and Ice.

Fire and Ice

GET /card/:name

Returns a JSON representation of the specified card. The response does not include version-specific metadata such as flavor text and rarity.

JSON response

Attributes

These attributes may be included in a response:

  • name
  • mana_cost
  • converted_mana_cost
  • supertypes
  • types
  • subtypes
  • text
  • flavor_text
  • flavor_text_attribution
  • color_indicator
  • watermark
  • power
  • toughness
  • loyalty
  • expansion
  • rarity
  • number
  • artist
  • gatherer_url
  • image_url
  • versions
  • community_rating
  • rulings

Attributes not applicable to the card type (e.g. lands have no mana cost) or not present (e.g. certain creatures have no rules text) are omitted.

GET /language/:id or GET /language/:name

Returns, as JSON, codes of the various languages in which the specified card is printed. Each language code has an associated card name and Gatherer id. For example:

{
  "de": {
    "id": 167618,
    "name": "Erhabener Engel"
  },
  "fr": {
    "id": 167975,
    "name": "Ange exalté"
  },
  "it": {
    "id": 168340,
    "name": "Angelo Eminente"
  },
  "pt-BR": {
    "id": 168690,
    "name": "Anjo Exaltado"
  },
  "es": {
    "id": 170279,
    "name": "Ángel exaltado"
  }
}

GET /set/:name/:page?

Returns a page of cards (up to 25) from the specified set. The first page of results is returned if page is omitted. Responses contain page, pages, and cards. For example:

page: 1
pages: 5
cards: [...]

Each card in cards contains all applicable attributes among the following:

  • name
  • mana_cost
  • converted_mana_cost
  • supertypes
  • types
  • subtypes
  • text
  • power
  • toughness
  • loyalty
  • expansion
  • rarity
  • gatherer_url
  • image_url
  • versions

Running the tests

$ npm test

tutor's People

Contributors

davidchambers avatar nicknovitski avatar

Watchers

 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.