Permalink
Browse files

API v4. Closes #34.

  • Loading branch information...
1 parent 7241074 commit e232071d84bc15a40c7dcac5e243827ead25047f @glacials committed Sep 30, 2016
Showing with 250 additions and 35 deletions.
  1. +1 −1 api/3/sets.json
  2. +74 −0 api/4/sets.json
  3. +35 −20 api/README.md
  4. +2 −2 package.json
  5. +138 −12 test/api.js
View
@@ -51,6 +51,6 @@
"symbol": "http://whatsinstandard.com/img/kld.jpg",
"enter_date": "2016-09-30T00:00:00.000Z",
"exit_date": null,
- "rough_exit_date": "early/mid 2017"
+ "rough_exit_date": "early/mid 2018"
}
]
View
@@ -0,0 +1,74 @@
+[
+ {
+ "name": "Battle for Zendikar",
+ "block": "Battle for Zendikar",
+ "code": "BFZ",
+ "enter_date": "2015-10-02T00:00:00.000Z",
+ "exit_date": "2017-04-28T00:00:00.000Z",
+ "rough_exit_date": "Q2 2017"
+ },
+ {
+ "name": "Oath of the Gatewatch",
+ "block": "Battle for Zendikar",
+ "code": "OGW",
+ "enter_date": "2016-01-22T00:00:00.000Z",
+ "exit_date": "2017-04-28T00:00:00.000Z",
+ "rough_exit_date": "Q2 2017"
+ },
+ {
+ "name": "Shadows over Innistrad",
+ "block": "Shadows over Innistrad",
+ "code": "SOI",
+ "enter_date": "2016-04-08T00:00:00.000Z",
+ "exit_date": null,
+ "rough_exit_date": "Q4 2017"
+ },
+ {
+ "name": "Welcome Deck 2016",
+ "block": "Shadows over Innistrad",
+ "code": "W16",
+ "enter_date": "2016-04-09T00:00:00.000Z",
+ "exit_date": null,
+ "rough_exit_date": "Q4 2017"
+ },
+ {
+ "name": "Eldritch Moon",
+ "block": "Shadows over Innistrad",
+ "code": "EMN",
+ "enter_date": "2016-07-21T00:00:00.000Z",
+ "exit_date": null,
+ "rough_exit_date": "Q4 2017"
+ },
+ {
+ "name": "Kaladesh",
+ "block": "Kaladesh",
+ "code": "KLD",
+ "enter_date": "2016-09-30T00:00:00.000Z",
+ "exit_date": null,
+ "rough_exit_date": "Q2 2018"
+ },
+ {
+ "name": "Aether Revolt",
+ "block": "Kaladesh",
+ "code": "AER",
+ "enter_date": "2017-01-20T00:00:00.000Z",
+ "exit_date": null,
+ "rough_exit_date": "Q2 2018"
+ },
+ {
+ "name": "Amonkhet",
+ "block": "Amonkhet",
+ "code": "AKH",
+ "enter_date": "2017-04-28T00:00:00.000Z",
+ "exit_date": null,
+ "rough_exit_date": "Q4 2018"
+ },
+ {
+ "name": "Hour of Devastation",
+ "block": "Amonkhet",
+ "code": "HOU",
+ "enter_date": "2017-07-14T00:00:00.000Z",
+ "exit_date": null,
+ "rough_exit_date": "Q4 2018"
+ }
+]
View
@@ -1,23 +1,21 @@
## API
-
Hey, welcome to this super awesome API. It's generated by me, a human. It has one endpoint! Here is an example request:
```bash
-curl whatsinstandard.com/api/3/sets.json
+curl whatsinstandard.com/api/4/sets.json
```
This will return something like:
```json
[
{
- "name": "Dragons of Tarkir",
- "block": "Khans of Tarkir",
- "code": "DTK",
- "symbol": "http://whatsinstandard.com/img/dtk.svg",
- "enter_date": "2015-03-27T00:00:00.000Z",
- "exit_date": null,
- "rough_exit_date": "late 2016"
+ "name": "Battle for Zendikar",
+ "block": "Battle for Zendikar",
+ "code": "BFZ",
+ "enter_date": "2015-10-02T00:00:00.000Z",
+ "exit_date": "2017-04-28T00:00:00.000Z",
+ "rough_exit_date": "Q2 2017"
},
...
]
@@ -26,26 +24,43 @@ This will return something like:
But you can just [visit it yourself][1] to see everything. You'll get some JSON containing an array of Magic sets. Each
set has some fields:
-| field | type | description |
-|:----------------- |:------------------------------------------------------------------- |:----------------------------------------- |
-| `name` | string | human-readable name of the set |
-| `block` | string, or `null` if a core set | human-readable name of the set's block |
-| `code` | string, matching regex `/[A-Z]{3}/` | official three-character code of the set |
-| `symbol` | string | URL to the official set image |
-| `enter_date` | string | release date of the set |
-| `exit_date` | string, or `null` if not exactly known | date the set exits Standard, if known |
-| `rough_exit_date` | string, matching regex <code>/(early\/mid&#124;late) 20\d\d/</code> | rough time of year the set exits Standard |
+| field | type | description |
+|:------------------|:-------------------------------------------------|:------------------------------------------|
+| `name` | string | human-readable name of the set |
+| `block` | string | human-readable name of the set's block |
+| `code` | string, matching regex `/[A-Z]{3}/` | official three-character code of the set |
+| `enter_date` | string | release date of the set |
+| `exit_date` | string, or `null` if not exactly known | date the set exits Standard, if known |
+| `rough_exit_date` | string, matching regex <code>/Q\d 20\d\d/</code> | rough time of year the set exits Standard |
-The sets array is guaranteed to be in order of release (aka `enter_date`), from oldest set to newest.
+The sets array is in order of release (aka `enter_date`), from oldest set to newest. It contains all sets in Standard as
+well as the next two or three sets to enter Standard. You can use `enter_date` to filter the list into only-released (or
+only-unreleased) sets by comparing it to today's date.
-### Versioning
+### Set images
+You can fetch set images from Gatherer by inserting the set's `code` into this URL template:
+
+ http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&size=large&rarity=C&set=CODE_GOES_HERE
+You can change the `rarity` parameter to any of `C`, `U`, `R`, or `M` to get the set image for common, uncommon, rare,
+or mythic rare rarities respectively.
+
+### Versioning
I only mention the most recent version of the API above. All previous versions are deprecated gradually -- sets that
fall out of Standard are removed from them properly, but newly-released sets are never added. So, all non-current API
versions will eventually return `[]`.
#### Changelog
+##### Version 4
+* Upcoming sets are once again included in the sets array. To use only released sets or only unreleased sets, filter on
+ `enter_date`.
+* `block` can no longer be `null`, as no more core sets will enter Standard.
+* The `symbol` field has been removed to decrease maintenance work. If you'd like still like to fetch set images, you
+ can instead use the `code` field to construct an image URL like
+ `http://gatherer.wizards.com/Handlers/Image.ashx?type=symbol&set=<code>&size=large&rarity=C`.
+* `rough_exit_date` regex has changed from `/(early\/mid|late 20\d\d/` to `/Q\d 20\d\d/` for simplicity.
+
##### Version 3
Valid `rough_exit_date` regex has changed from `/(early|late) 20\d\d/` to `/(early\/mid|late) 20\d\d/` to account for
the new Standard rotation style. Old API versions will continue to match their respective regexes, but with potentially
View
@@ -9,8 +9,8 @@
"test": "./node_modules/mocha/bin/mocha"
},
"devDependencies": {
- "mocha": "~2.3.3",
- "chai": "~3.3.0",
+ "mocha": "*",
+ "chai": "*",
"supervisor": "~0.9.1"
}
}
Oops, something went wrong.

0 comments on commit e232071

Please sign in to comment.