Skip to content

BlueMonday/go-scryfall

Repository files navigation

go-scryfall

Go PkgGoDev Coverage Status Go Report Card

go-scryfall

go-scryfall is a Golang client library for accessing the Scryfall API.

The Scryfall logo is copyrighted by Scryfall, LLC. go-scryfall is not created by, affiliated with, or supported by Scryfall.

go-scryfall art was provided by @jouste the fierce drawbarian!

Example

package main

import (
	"context"
	"log"

	scryfall "github.com/BlueMonday/go-scryfall"
)

func main() {
	ctx := context.Background()
	client, err := scryfall.NewClient()
	if err != nil {
		log.Fatal(err)
	}

	sco := scryfall.SearchCardsOptions{
		Unique:        scryfall.UniqueModePrints,
		Order:         scryfall.OrderSet,
		Dir:           scryfall.DirDesc,
		IncludeExtras: true,
	}
	result, err := client.SearchCards(ctx, "storm cro", sco)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("%s", result.Cards[0].Colors)
}

Rate Limiting

go-scryfall will rate limit requests to Scryfall's API. The default limit is 10 requests per second as recommended in the REST API documentation.

To disable rate limiting use the WithLimiter option with a nil limiter when constructing the client.

package main

import (
	"log"

	scryfall "github.com/BlueMonday/go-scryfall"
)

func main() {
	client, err := scryfall.NewClient(scryfall.WithLimiter(nil))
	if err != nil {
		log.Fatal(err)
	}
}