Skip to content

Commit

Permalink
API v4. Closes #34.
Browse files Browse the repository at this point in the history
  • Loading branch information
glacials committed Oct 1, 2016
1 parent 7241074 commit e232071
Show file tree
Hide file tree
Showing 5 changed files with 250 additions and 35 deletions.
2 changes: 1 addition & 1 deletion api/3/sets.json
Expand Up @@ -51,6 +51,6 @@
"symbol": "http://whatsinstandard.com/img/kld.jpg", "symbol": "http://whatsinstandard.com/img/kld.jpg",
"enter_date": "2016-09-30T00:00:00.000Z", "enter_date": "2016-09-30T00:00:00.000Z",
"exit_date": null, "exit_date": null,
"rough_exit_date": "early/mid 2017" "rough_exit_date": "early/mid 2018"
} }
] ]
74 changes: 74 additions & 0 deletions api/4/sets.json
@@ -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"
}
]
55 changes: 35 additions & 20 deletions api/README.md
@@ -1,23 +1,21 @@
## API ## API

Hey, welcome to this super awesome API. It's generated by me, a human. It has one endpoint! Here is an example request: Hey, welcome to this super awesome API. It's generated by me, a human. It has one endpoint! Here is an example request:


```bash ```bash
curl whatsinstandard.com/api/3/sets.json curl whatsinstandard.com/api/4/sets.json
``` ```


This will return something like: This will return something like:


```json ```json
[ [
{ {
"name": "Dragons of Tarkir", "name": "Battle for Zendikar",
"block": "Khans of Tarkir", "block": "Battle for Zendikar",
"code": "DTK", "code": "BFZ",
"symbol": "http://whatsinstandard.com/img/dtk.svg", "enter_date": "2015-10-02T00:00:00.000Z",
"enter_date": "2015-03-27T00:00:00.000Z", "exit_date": "2017-04-28T00:00:00.000Z",
"exit_date": null, "rough_exit_date": "Q2 2017"
"rough_exit_date": "late 2016"
}, },
... ...
] ]
Expand All @@ -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 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: set has some fields:


| field | type | description | | field | type | description |
|:----------------- |:------------------------------------------------------------------- |:----------------------------------------- | |:------------------|:-------------------------------------------------|:------------------------------------------|
| `name` | string | human-readable name of the set | | `name` | string | human-readable name of the set |
| `block` | string, or `null` if a core set | human-readable name of the set's block | | `block` | string | human-readable name of the set's block |
| `code` | string, matching regex `/[A-Z]{3}/` | official three-character code of the set | | `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 |
| `enter_date` | string | release date of the set | | `exit_date` | string, or `null` if not exactly known | date the set exits Standard, if known |
| `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 |
| `rough_exit_date` | string, matching regex <code>/(early\/mid&#124;late) 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 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 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 `[]`. versions will eventually return `[]`.


#### Changelog #### 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 ##### 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 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 the new Standard rotation style. Old API versions will continue to match their respective regexes, but with potentially
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -9,8 +9,8 @@
"test": "./node_modules/mocha/bin/mocha" "test": "./node_modules/mocha/bin/mocha"
}, },
"devDependencies": { "devDependencies": {
"mocha": "~2.3.3", "mocha": "*",
"chai": "~3.3.0", "chai": "*",
"supervisor": "~0.9.1" "supervisor": "~0.9.1"
} }
} }

0 comments on commit e232071

Please sign in to comment.