scruffy
scruffy is a Gleam client for the
Scryfall Magic: The Gathering API.
The package ships the types modelling Scryfall’s objects – cards,
sets, rulings, symbols, and the other resources it exposes – and a
*_schema() JSON decoder for each of them, built with
Glon. scruffy/client/* builds on top of
that with a function per Scryfall endpoint that sends the request and
decodes the response for you, via scruffy/client.
Call new once with your client.Requester to get every one of those
functions back, already wired up to it and grouped the way Scryfall
groups its own endpoints:
import gleam/httpc
import scruffy
let scryfall = scruffy.new(httpc.send)
scryfall.cards.get_card_by_id("bd8fa327-dd41-4737-8f19-2cf5eb1f7cdd")
scryfall.catalogs.get_card_names()
Types
Every Scryfall endpoint function, grouped by resource and already wired
up to a Requester – see new.
pub type Client(e) {
Client(
cards: cards.Client(e),
catalogs: catalogs.Client(e),
bulk_data: bulk_data.Client(e),
migrations: migrations.Client(e),
)
}
Constructors
-
Client( cards: cards.Client(e), catalogs: catalogs.Client(e), bulk_data: bulk_data.Client(e), migrations: migrations.Client(e), )
Values
pub fn new(
requester: fn(request.Request(String)) -> Result(
response.Response(String),
e,
),
) -> Client(e)
Build a Client bound to the given Requester. On Erlang, that’s
gleam_httpc’s send, unchanged: scruffy.new(httpc.send).