Git Product home page Git Product logo

scryfallkit's Introduction

ScryfallKit

Build and test Swift Version Compatibility Platform Support

A Swift Package for accessing Scryfall's REST API

Documentation

This library is largely a translation of Scryfall's REST API to a collection of Swift enums and structs. It is highly recommended that you read the official Scryfall API docs as the documentation in this project will not attempt to give in-depth explanations of how each of these endpoints work.

For the most up to date documentation, use the DocC pages published here

To generate these pages locally, use this command from Apple's Swift DocC plugin

swift package --disable-sandbox preview-documentation --target ScryfallKit

Getting Started

Add ScryfallKit to your project either through the Xcode UI, or through the process below for Swift Packages

let package = Package(
    // ... Other Package.swift stuff goes here
    dependencies: [
        .package(url: "https://github.com/JacobHearst/ScryfallKit", from: "5.0.0"), // Add the library to your manifest
    ],
    targets: [
        .target(name: "MyPackage", dependencies: ["ScryfallKit"]), // Add it to your target's dependencies
    ]
)

Example

import ScryfallKit

let client = ScryfallClient()

// Retrieve the Strixhaven Mystical Archive printing of Doom Blade
do {
    let doomBlade = try await client.getCardByName(exact: "Doom Blade", set: "STA")
    print(doomBlade.cmc)
} catch {
    print("Received error: \(error)")
}

// Or using a completion handler
client.getCardByName(exact: "Doom Blade", set: "STA") { result in
    switch result {
    case .success(let doomBlade):
        print(doomBlade.cmc)
    case .failure(let error):
        print("Received error: \(error)")
    }
}

Network Logging

The ScryfallClient has a configurable level of network logging with two options: minimal and verbose. Enabling verbose logging will print the HTTP body of each request and response. Minimal logging will log that a request was made (and the URL it's made to) as well as that a response was received.

Contributing

Contributions are always welcome, simply fork this repo, make and test your changes, and then open a pull request. I will try and review it within a reasonable amount of time.

scryfallkit's People

Contributors

bonney avatar jacobhearst avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

missingems bonney

scryfallkit's Issues

`art_crop` and `border_crop` URIs Missing from Cards

Hello! I am having an issue where Card objects returned from the API are missing the art_crop and border_crop image URI. All other sizes return proper URLs. See attached photo.

My guess is this is a Codable issue, although your code appears to have the proper coding keys set in the ImageUris struct.

As a test I have confirmed the direct Scryfall API returns URLs for both art and border crops that are valid, and will successfully load in a SwiftUI AsyncImage.

Screenshot 2024-05-14 at 11 47 26 AM

Not Related to this lib

Hi

I was using your lib GCDWebserver using SPM but I think you have deleted it ?

Could you pl share the lib so I can continue using it or anyother way to use this

Thanks

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.