{"id":15038375,"url":"https://github.com/bmbowdish/swiftfall","last_synced_at":"2025-04-09T23:40:55.807Z","repository":{"id":49211725,"uuid":"122785315","full_name":"bmbowdish/Swiftfall","owner":"bmbowdish","description":"Wrapper for Scryfall API written in Swift","archived":false,"fork":false,"pushed_at":"2021-06-23T11:51:52.000Z","size":107,"stargazers_count":22,"open_issues_count":6,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-08T14:02:39.132Z","etag":null,"topics":["api-wrapper","json-api","magic-the-gathering","mtg-api","scryfall","scryfall-api","swift","swift-4","swift-library","swift4"],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bmbowdish.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-24T22:26:15.000Z","updated_at":"2025-04-04T16:50:38.000Z","dependencies_parsed_at":"2022-09-07T10:12:04.324Z","dependency_job_id":null,"html_url":"https://github.com/bmbowdish/Swiftfall","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmbowdish%2FSwiftfall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmbowdish%2FSwiftfall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmbowdish%2FSwiftfall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bmbowdish%2FSwiftfall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bmbowdish","download_url":"https://codeload.github.com/bmbowdish/Swiftfall/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248131468,"owners_count":21052819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","json-api","magic-the-gathering","mtg-api","scryfall","scryfall-api","swift","swift-4","swift-library","swift4"],"created_at":"2024-09-24T20:38:13.444Z","updated_at":"2025-04-09T23:40:55.769Z","avatar_url":"https://github.com/bmbowdish.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swiftfall\nSwiftfall is a wrapper written in Swift for the API Scryfall.\n\n[Documentation for Scryfall API.](https://scryfall.com/docs/api)\n\nScryfall is API which handles information about the card game Magic: The Gathering. \n\n# Swiftfall Documentation\n## Types\nAll types are Structs and can be reach through a Swiftfall.get*(). \n\n### Types That Hold Data\n#### Card \n * Struct containing data about a Magic Card.\n * Contains the **Card.Face** Struct\n   * Some Cards have faces, **Card.Face** contains those faces. \n#### ScryfallSet\n * Struct containing data about a Set of Magic cards.\n * named ScryfallSet due to Set already existing in Swift.\n#### Ruling\n * Struct containing data about a Magic Card's rulings. \n#### Catalog\n * Struct containing data about Magic. \n * Example: \"land-types\"\n### Structs which contain Arrays of Types \n#### CardList \n * Struct containing a list of Cards.\n#### SetList \n * Struct containing a list of ScryfallSets.\n#### RulingList\n * Struct containing a list of Rulings.\n## Functions\nThese are some functions you can call which will handle information from Scryfall's API. \n\n### Get a Card\nSwiftfall.getCard(fuzzy:String) throws -\u003e Card _(Fuzzy search)_\n\nSwiftfall.getCard(exact:String) throws -\u003e Card _(Exact search)_\n\nSwiftfall.getCard(code: String, number: Int) throws -\u003e Card _(Set Code, ID Number)_\n\nSwiftfall.getRandomCard() throws -\u003e Card _(Random Card)_\n\n... and more! \n\nEx.\n``` \nimport Swiftfall\ndo {\n  let card = try Swiftfall.getCard(exact:\"Black Lotus\")\n  print(card)\n  } catch {\n    print(error)\n}\n```\nOut.\n```\nName: Black Lotus\nCost: {0}\nType Line: Artifact\nOracle Text:\n{T}, Sacrifice Black Lotus: Add three mana of any one color to your mana pool.\n```\n\n#### Double-Sided Cards\n\nEx.\n``` \nimport Swiftfall\ndo {\n  let card = try Swiftfall.getCard(exact:\"Jace, Vryn's Prodigy\")\n  let faces = card.cardFaces\n  let front = faces![0]\n  let back = faces![1]\n  print(front)\n  print(back)\n  } catch {\n    print(error)\n}\n```\nOut. \n```\nName: Jace, Vryn's Prodigy\nCost: {1}{U}\nType Line: Legendary Creature — Human Wizard\nOracle Text:\n{T}: Draw a card, then discard a card. If there are five or more cards in your graveyard, exile Jace, Vryn's Prodigy, then return him to the battlefield transformed under his owner's control.\nPower: 0\nToughness: 2\nName: Jace, Telepath Unbound\nCost: \nType Line: Legendary Planeswalker — Jace\nOracle Text:\n+1: Up to one target creature gets -2/-0 until your next turn.\n−3: You may cast target instant or sorcery card from your graveyard this turn. If that card would be put into your graveyard this turn, exile it instead.\n−9: You get an emblem with \"Whenever you cast a spell, target opponent puts the top five cards of his or her library into his or her graveyard.\"\nLoyalty: 5\n```\n\n### Get a list of Cards\nSwiftfall.getCardList() throws -\u003e CardList _(The first page)_\n\nSwiftfall.getCardList(page:Int) throws -\u003e CardList _(Loads a specific page)_\n\nEx. \n```\nimport Swiftfall\ndo {\n  let cardlist = try Swiftfall.getCardList(page:0) // this is the same as .getCardList()\n  print(cardlist)\n} catch {\n  print(error)\n}\n```\n\n\n### Get a ScryfallSet\nSwiftfall.getSet(code:String) throws -\u003e Set _(String must be a three letter code)_\n\nEx.\n```\nimport Swiftfall\ndo { \n  let set = try Swiftfall.getSet(code: \"KTK\")\n  print(set) \n} catch {\n  print(error)\n}\n```\nOut.\n```\nName: Khans of Tarkir (ktk)\nBlock: Khans of Tarkir\nNumber of Cards: 269\nRelease Date: 2014-09-26\nSet Type: expansion\n```\n\n### Get a list of Cards in a Set\n\nSet.getCards() -\u003e \\[CardList?\\] _(an array of CardLists which each contain a portion of a set)_\n\nEx. \n```\nimport Swiftfall\ndo {\n    let set = try Swiftfall.getSet(code: \"PRM\")\n    let cards = set.getCards()\n} catch {\n    print(error)\n}\n```\n\n### Get a list of ScryfallSets\nSwiftfall.getSetList() throws -\u003e SetList _(All Sets)_\n\nEx.\n```\nimport Swiftfall\ndo {\n  let setlist = try Swiftfall.getSetList()\n  print(setlist)\n} catch {\n  print(error)\n}\n```\n\n### Get a list of Rulings\nSwiftfall.getRulingList(code:String,number:Int) throws -\u003e RulingList\n\nEx.\n``` \nimport Swiftfall\ndo {\n  let rulings = try Swiftfall.getRulingList(code: \"ima\", number: 65)\n  print(rulings)\n} catch {\n  print(error)\n}\n```\n\n### Get a Ruling\nTo get a specific ruling you must first get a Ruling List. \n\nOnce you have a RulingList you may call .data\\[index: Int\\]\n\nEx. \n```\nimport Swiftfall\ndo {\n  let rulings = try Swiftfall.getRulingList(code: \"ima\", number: 65)\n  let ruling = rulings.data[1]\n  print(ruling)\n} catch {\n  print(error)\n}\n```\n\n### Get a Catalog\nCatalog objects are provided by the API as aids for building other Magic software and understanding possible values for a field on Card objects.\nEx. \n```\nimport Swiftfall\ndo {\n  let catalog = try Swiftfall.getCatalog(catalog: \"land-types\")\n  print(catalog)\n} catch {\n  print(error)\n}\n```\nOut. \n```\nDesert\nForest\nGate\nIsland\nLair\nLocus\nMine\nMountain\nPlains\nPower-Plant\nSwamp\nTower\nUrza’s\n\n```\n\n## Testing \n\nTesting allows for us to check certain scenarios quickly and determine the problems in a easy to understand and grasp manner. \n\n### Example\nEx. \n```\nfunc testRandomCard(){\n    do { \n      _ = try Swiftfall.getRandomCard()\n    } catch {\n      print(error)\n      XCTFail()\n    }\n}\n```\n\n# How to set up Swiftfall\nFirst, create an executable package. The executable includes a Hello World function by default. \n```\n$ mkdir MyExecutable\n$ cd MyExecutable\n$ swift package init --type executable\n$ swift build\n$ swift run\nHello, World!\n```\n\nNext, \n\n```\n$ swift package generate-xcodeproj\n```\nThen, set Swiftfall as a dependency for the executable.\n\n```\nimport PackageDescription\n\nlet package = Package(\n    name: \"MyExecutable\",\n    dependencies: [\n        // Dependencies declare other packages that this package depends on.\n        // .package(url: /* package url */, from: \"1.0.0\"),\n        .package(url:\"https://github.com/bmbowdish/Swiftfall.git\", from: \"1.2.0\")\n    ],\n    targets: [\n        // Targets are the basic building blocks of a package. A target can define a module or a test suite.\n        // Targets can depend on other targets in this package, and on products in packages which this package depends on.\n        .target(\n            name: \"MyExecutable\",\n            dependencies: [\"Swiftfall\"]),\n    ]\n)\n```\n\nThen, run:\n\n```\n$ swift package generate-xcodeproj\n```\n\nNow you're ready to use Swiftfall!\n\nIf you are interested in checking out a project using Swiftfall you can checkout:\n\nhttps://github.com/bmbowdish/Test-Swiftfall\n\n# Catalog Examples\ncard-names\n\nword-bank\n\ncreature-types\n\nplaneswalker-types\n\nland-types\n\nspell-types\n\nartifact-types\n\npowers\n\ntoughnesses\n\nloyalties\n\nwatermarks\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmbowdish%2Fswiftfall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbmbowdish%2Fswiftfall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbmbowdish%2Fswiftfall/lists"}