Swiftpack.co - JacobHearst/ScryfallKit as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by JacobHearst.
JacobHearst/ScryfallKit v3.0.0
A Swift SDK for the Scryfall API
⭐️ 0
🕓 Yesterday
iOS macOS
.package(url: "https://github.com/JacobHearst/ScryfallKit.git", from: "v3.0.0")

ScryfallKit

Build and test

A Swift Package for accessing Scryfall's REST API

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: "3.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
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)")
    }
}

// Or using async
do {
    let doomBlade = try await client.getCardByName(exact: "Doom Blade", set: "STA")
    print(doomBlade.cmc)
} catch {
    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.

GitHub

link
Stars: 0
Last commit: Yesterday
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

v3.0.0 Change type names
Yesterday

There was some overlap between the terminology used in Scryfall's API and some built in types of Swift/SwiftUI. These types have been renamed to make it clearer what is being referenced.

Renamed types:

  • Color -> CardColor
  • List -> ObjectList
  • Set -> MTGSet

Other improvements:

  • Rarities are now comparable
    • bonus < special < common < uncommon < rare < mythic
  • Colors are now comparable
    • W < U < B < R < G < C

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics