|
| 1 | +# Scryfall API types |
| 2 | + |
| 3 | +This library documents the definitive comprehensive typings of the Scryfall API for use in Typescript & Javascript projects. |
| 4 | + |
| 5 | +This library uses [semver] for versioning. These versions only describe this library, not the Scryfall API as a whole. |
| 6 | + |
| 7 | +[semver]: https://semver.org/ |
| 8 | + |
| 9 | +## Details |
| 10 | + |
| 11 | +All exported types are prefixed with `Scryfall`, so that we can declare e.g. `ScryfallSet`, `ScryfallObject`, and `ScryfallError` without clashing with the built-in `Set`, `Object`, and `Error` types. |
| 12 | + |
| 13 | +Enum fields are always defined in two ways: as the Enum, and as an Enum-like string. This permits you to interact with this system using our enums, just strings, or your own enums—whatever you'd prefer. |
| 14 | + |
| 15 | +## Using this as a dependency for your library |
| 16 | + |
| 17 | +There's essentially three ways you might use this project: |
| 18 | + |
| 19 | +- Your own independent project that nobody will be installing as a dependency. |
| 20 | +- Your own library that requires this as a dependency, and which others will install. |
| 21 | + |
| 22 | +In the first case, install this as a dependency or a dev dependency. |
| 23 | + |
| 24 | +In the second case, consider whether you are forwarding Scryfall types on to consumers of your library. |
| 25 | + |
| 26 | +- Are you converting our data to your own system of types, and supplying those to consumers? (e.g. you're writing a Scryfall API that has its own rigorous way of describing cards) |
| 27 | +- Are you supplying these objects as-is to consumers? (e.g. you're writing a Scryfall API that just fetches cards and returns them as-is using our typing) |
| 28 | + |
| 29 | +In the first of these cases, we advise you install this as a dev dependency. |
| 30 | + |
| 31 | +In the second case however, we advise you require a given major version of this library **as a peer dependency, not a dependency**, so that consumers of your library can continue to update their reference to the Scryfall API without requiring you to do so as well, as follows: |
| 32 | + |
| 33 | +```js |
| 34 | +// in package.json |
| 35 | +{ |
| 36 | + name: "mylibrary", |
| 37 | + peerDependencies: { |
| 38 | + // The major version others should use. |
| 39 | + "@scryfall/api-types": "1.x", |
| 40 | + }, |
| 41 | + devDependencies: { |
| 42 | + // The version you use for your work. |
| 43 | + "@scryfall/api-types": "1.2.3", |
| 44 | + } |
| 45 | +} |
| 46 | +``` |
0 commit comments