Skip to content

Commit bce5a78

Browse files
committed
examples in readme
1 parent 33d2f16 commit bce5a78

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,36 @@ This library documents the definitive comprehensive typings of [the Scryfall API
44

55
This library uses [semver] for versioning. These versions only describe this library, not the Scryfall API as a whole.
66

7+
## Examples
8+
9+
### Fetching a card
10+
11+
```ts
12+
// CommonJS module syntax
13+
const { ScryfallCard } = require("@scryfall/api-types");
14+
15+
// ES module syntax
16+
import { ScryfallCard } from "@scryfall/api-types";
17+
18+
// Fetch a card
19+
const response = await fetch("https://api.scryfall.com/cards/iko/275");
20+
const godzilla: ScryfallCard.Any = await response.json();
21+
```
22+
23+
### Fetching the list of sets
24+
25+
```ts
26+
// CommonJS module syntax
27+
const { ScryfallList } = require("@scryfall/api-types");
28+
29+
// ES module syntax
30+
import { ScryfallList } from "@scryfall/api-types";
31+
32+
// Fetch the list of all setss
33+
const response = await fetch("https://api.scryfall.com/sets");
34+
const sets: ScryfallList.Sets = await response.json();
35+
```
36+
737
## Usage
838

939
Each type and enum exported by this library corresponds to a Scryfall API object and its values.

0 commit comments

Comments
 (0)