Giter Club home page Giter Club logo

scryfall-rails's Introduction

scryfall-rails

Gem Version CircleCI

A simple gem that utilizes the Scryfall API to get Magic: the Gathering card information.

Instalation

It will only be needed to specify it on your Gemfile:

gem 'scryfall'

And then run the Bundler

bundle install

Usage

The Scryfall module have classes for each query on the Scryfall API. Each class will reflect a module of query.

At first, there are only a few methods available:

::Cards

Using require "scryfall/cards", you will have access to the Scryfall::Cards class. It encapsulates the logics on the API that returns a set of cards, or an object representing a single one.

Named (fuzzy and exact)

It searches for cards named almost as the string passed (fuzzy), or with the exact name as the string passed (exact)

# Fuzzy
Scryfall::Cards.named_fuzzy "aust commd"

# Exact
Scryfall::Cards.named_exact "Counterspell"

Search Query

It can search a list of cards using the Scryfall syntax

# The search will return all the cards that fits on the query parameters
Scryfall::Cards.search "f:standard t:land id:UW"

# It can be passed the page of the search. Each page of data has a maximum of 175 cards
Scryfall::Cards.search "f:standard t:creature", page: 2

By IDs

The Scryfall::Cards class has methods to retrieve cards by its identifier in multiple platforms.

# Returning the "Yargle, Glutton of Urborg" card by its IDs

# can be fetched by its MTGO id ...
Scryfall::Cards.with_mtgo_id 67691

# ... by its Arena id ...
Scryfall::Cards.with_arena_id 67330

# ... by its TCG Player id ...
Scryfall::Cards.with_tcgplayer_id 164756

# ... or by its unique ID.
Scryfall::Cards.with_id "645cfc1b-76f2-4823-9fb0-03cb009f8b32"

Cards that are not on those systems can't be retrieved by its ids. For example, the Austere Command card can't be fetched by an Arena Id because the card isn't in the game.

Responses

The default response for all calls are JSON. If a to_struct: true is passed as argument, the return will be a OpenStruct Hash object.

scryfall-rails's People

Contributors

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