Code Monkey home page Code Monkey logo

go-scryfall's Introduction

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)
	}
}

go-scryfall's People

Contributors

bluemonday avatar dependabot[bot] avatar eathox avatar iammoonman avatar jeandeaual avatar lexfrei avatar pietroglyph avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

go-scryfall's Issues

Run tests on PR

Hi!
Do you need any help with ci/cd?
As you can see in #15, someone (ex.: me) can miss tests or else. Such PRs have to be blocked automatically to save your time.
It's easy to do some checks with Travis, GH Actions or something else.
Feel free to ask me for any help you need.

unknown time zone

Unexpected error: unknown time zone Etc/GMT+8
ENV: Alpine image, running in Docker, DigidtalOcean
This error appears for some search worlds like 'negate', but it works fine for 'отвергнуть'
(the Russian name for this card). I can't see any correlation between cards and error, but it happens all the time for the same cards.
Also, all worked for my old code with a simple query generator and JSON unmarshal.
Also, all worked well on a local machine, the error appears only in Docker. Probably related to Alpine minimal env without preinstalled tzdata

My code (full):

func FuzzInline(text string) {
	ctx := context.Background()

	client, err := scryfall.NewClient()
	if err != nil {
		log.Println("can't create scryfall client:", err)
		return
	}

	result, err := client.SearchCards(ctx, text, scryfall.SearchCardsOptions{Unique: scryfall.UniqueModeCards, IncludeMultilingual: true})
	if err != nil {
		log.Printf("can't fuzz search for \"%s\": %s", text, err)
		return
	}
	<...>
}

So, now by log looks like this:

2019/09/29 00:45:31 can't fuzz search for "negate": unknown time zone Etc/GMT+8
2019/09/29 00:45:32 can't fuzz search for "negate": unknown time zone Etc/GMT+8

Prices missing

The prices strings are empty even though the scryfall's json contains them.

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.