Crate scryfall

source ·
Expand description

Scryfall provides a REST-like API for ingesting our card data programatically. The API exposes information available on the regular site in easy-to-consume formats.

§Cards

The main way to fetch cards from this API is the Card struct.

This allows you to get cards from scryfall using all of their available REST Apis

use scryfall::card::Card;
match Card::named_fuzzy("Light Bolt").await {
    Ok(card) => assert_eq!(card.name, "Lightning Bolt"),
    Err(e) => panic!("{e:?}"),
}

Double faced cards have some of their properties inside the card_faces array instead of at the top level.

use scryfall::card::{Card, Color};

match Card::named("Delver of Secrets").await {
    Ok(card) => {
        assert!(card.colors.is_none());
        assert_eq!(card.card_faces.unwrap()[0].colors, Some(vec![Color::Blue]));
    }
    Err(e) => panic!("{e:?}"),
}

§Sets

You can also fetch information about a card set.

The available routes for this can be seen on Set

use scryfall::set::Set;
assert_eq!(Set::code("mmq").await.unwrap().name, "Mercadian Masques")

§Catalogs

Finally scryfall also allows you to fetch catalogs which are collections of Magic the Gathering data points.

For example, one could fetch all available card names.

use scryfall::catalog::Catalog;
assert!(Catalog::card_names().await.unwrap().data.len() > 0)

One of the main features of scryfall is its advanced search. For this the search module provides a type safe api to interact and query the search engine. For advanced features like sorting and collation, see search::advanced.

Re-exports§

Modules§

  • Scryfall provides daily exports of their card data in bulk files. Each of these files is represented as a bulk_data object via the API. URLs for files change their timestamp each day, and can be fetched programmatically.
  • This module provides a definition of a Magic: The Gathering card, as well as, ways to fetch them from scryfall.
  • A Catalog object contains an array of Magic datapoints (words, card values, etc). Catalog objects are provided by the API as aids for building other Magic software and understanding possible values for a field on Card objects.
  • This module exposes the possible errors this crate has, and ways to interact with them.
  • The available magic the gathering formats.
  • A List object represents a requested sequence of other objects (Cards, Sets, etc). List objects may be paginated, and also include information about issues raised when generating the list.
  • Rulings represent Oracle rulings, Wizards of the Coast set release notes, or Scryfall notes for a particular card.
  • This module provides an abstraction over the search parameters available in Scryfall. For a complete documentation, refer to the official site.
  • A Set object represents a group of related Magic cards. All Card objects on Scryfall belong to exactly one set.
  • Module for handling unresolved URLs returned by the scryfall api

Type Aliases§

  • The result type used to describe all fallible operations of the scryfall crate.