lifecycle

Travis build status Codecov test coverage

scryr provides R functions to access Scryfall's APIs for catalogs, sets, and card search.

Installation

Install scryr from Github with devtools

# install.packages("devtools")
library(devtools)
install_github("khailper/scryr")

Usage

library(tidyverse)
library(scryr)

scry_catalog()

Scryfall catalogs contain each unique value of the catalogs content, returned as a vector of strings. So, if you wanted every enchantment subtype:

scry_catalog("enchantment-types")

The list of available catalogs can be found with ?scry_catalog.

scry_sets()

scry_sets can either return a tibble containing the information for all sets (the default), or scry_sets("set's three letter") to get just the information for that set.

scry_sets("war")

scry_cards()

scry_cards() returns a tibble containing cards matching the seach in the queryarguement. So, if we instead of wanting the information about War of the Spark, we wanted all cards in that set:

war_cards <- scry_cards("s:war")
war_cards

scry_cards also supports more complex searches (the query syntax is available at https://scryfall.com/docs/syntax):

# all mono-colored creatures in War of the Spark"
scry_cards("set:war t:'creature' c:1") %>% 
  # need to unlist colors so it can be a grouping variable for count
  mutate(colors = unlist(colors),
         colors = fct_relevel(colors, "W", "U", "B", "R", "G")) %>% 
  # getting each color's mana curve
  count(cmc,colors) %>% 
  ggplot(aes(cmc, n, fill = colors)) +
  geom_col() +
  facet_wrap(~colors) + 
  guides(fill = FALSE) + 
  labs(title = "Mana curve by color in War of the Spark",
       subtitle = "mono-colored creatures only",
       x = "Converted mana cost", 
       y = "Number of cards") +
  theme(strip.background = element_blank(), strip.text.x = element_blank()) +
  scale_fill_manual(values = c("W" = "#ffe7b9",
                               "U" = "#0e68ab",
                               "B" = "#150b00",
                               "R" = "#d3202a",
                               "G" = "#00733e"))

Note: both scry_sets and scry_cards by default drop columns related containing IDs and URIs. This can be overridden with include_ids = TRUE and include_uris = TRUE, respectively.

scryr is unofficial Fan Content permitted under the Fan Content Policy. Not approved/endorsed by Wizards. Portions of the materials used are property of Wizards of the Coast. ©Wizards of the Coast LLC.

scryr is not endorsed or supported by Scryfall. Any use of scryr is subject to Scryfall's "Use of Scryfall Data" policy at https://scryfall.com/docs/api.

Please note that the 'scryr' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



khailper/scryr documentation built on Aug. 1, 2019, 9:35 p.m.