UNPKG

archidekt

Version:
205 lines (141 loc) 5.44 kB
# Archidekt [Archidekt] is a deck building website for the popular trading card game (TCG) Magic: the Gathering (MtG). The repository is not affiliated with or supported by [Archidekt] and users of this code base are responsible for following best practices ## API (official) At the moment [Archidekt] does not have documentation for their API and is currently in open beta. Therefore everything seen here in is open to change. ### decks The base URI for searching [Archidekt] for a deck by `https://archidekt.com/api/decks/(id)/` and has the following parameters: #### id > the integer corresponding to the deck's ID - example: `https://archidekt.com/api/decks/56723/` #### small > trailing slug to minifiy results - example `https://archidekt.com/api/decks/56723/small/` ### Search The base URI for searching [Archidekt] for decks is `https://archidekt.com/api/decks/cards/` and has the following parameters: #### name > search for decks with a given name. This is case _insensitive_ and returns decks that match the substring. To get decks with any name leave blank i.e. `name=` - required: true - default: `name=` - expects: non quoted string - values: empty or string - example: `name=dark angel` (would return a deck titled "Dark Angels Rising") #### colors > color identity of the deck. - required: false - default: `colors=White,Blue,Black,Green,Red,Colorless` - expects: comma separated list of not quoted colors - values: White, Blue, Black, Green, Red, Colorless - example: `colors=Blue,Black` #### logicalAnd > whether or not colors identity should be inclusive (all colors listed) or partial (any of the colors listed). Logical or is indicated by the exclusion of this field. - required: false - default: `` - expects: boolean - values: true - example `andcolors=true` #### owner > search via the _username_ who made the deck. Will match substrings - required: false - default: `` - expects: non quoted string - values: string - example `owner=sumneur` will return decks by `sumneuron` #### cards > search for decks including any of the cards listed. - required: false - default: `` - expects: url escaped comma separated list of quoted strings corresponding to valid card names in English - values: string - example `cards="Legion's Landing // Adanto, the First Fort","Ral, Storm Conduit"` will return decks containing either `"Legion's Landing // Adanto, the First Fort"` or `Ral, Storm Conduit` #### orderBy > the field on which to sort matching results. - required: false, - default: `orderBy=-createdAt` - expects: a non quoted string (possibly proceeded by a `-`) indicating the field on which to sort - values: string - example: `orderBy=owner` #### formats > the set of formats of which returned decks should adhere to > supported formats currently included ``` 1: Standard 2: Modern 3: Commander / EDH 4: Legacy 5: Vintage 6: Pauper 7: Custom 8: Frontier 9: Future Standard 10: Penny Dreadful 11: 1v1 Commander 12: Dual Commander 13: Brawl ``` - required: false - default: `` - expects: a comma separated list of integers in the domain `[1,13]` corresponding to the formats - values: 1,2,3,4,5,6,7,8,9,10,11,12,13 - example" `formats=1,2` (standard / modern decks) #### commanders > the commanders that should lead the deck. Note: this will be applied on formats that do _not_ have commanders! Note: this will match exclusively (only returns decks with all listed cards as commanders) - required: false - default: `` - expects: url escaped comma separated list of quoted strings corresponding to valid card names in English - values: string - example `commanders="Eight-and-a-Half-Tails"` will return decks containing `"Eight-and-a-Half-Tails"` as a commander. #### pageSize > how many decks to return per page. Note: excluding this field will return all decks - required: false - default: `pageSize=50` - expects: integer - values: positive integer - example" `pageSize=100` ------------------------- ### Examples #### Decks To help clarify the logic of [Archidekt]'s api we use the following decks to test combinations ##### Strombreaker This deck is of `format=7` (custom), includes the card `"Ral, Storm Conduit"`, has the color identity `Red,Blue` and was made by user `sumneuron`. #### Examples ##### 1 ``` &andcolors=true &cards="Legion's Landing // Adanto, the First Fort","Ral, Storm Conduit" &colors=White,Blue,Black,Green,Red,Colorless &owner=sumneur ``` Will not return the deck "Stormbreaker" which does not included the card `Legion's Landing // Adanto, the First Fort`. #### 2 ``` &cards="Legion's Landing // Adanto, the First Fort","Ral, Storm Conduit" &colors=White,Blue,Black,Green,Red,Colorless &owner=sumneur ``` Will return the deck "Stormbreaker" which does not included the card `Legion's Landing // Adanto, the First Fort`. ## API (this code base) ```js import archidekt from 'archidekt' // axios instance with base url `https://archidekt.com/api/` archidekt.api // axios get request for the given id. See "decks" above archidekt.fetchDeckById(id, small=true) // axios get request searching for decks with given parameters archidekt.searchDecks( { logicalAnd=false, owner=null, colors=['White', 'Blue', 'Black', 'Green', 'Red', 'Colorless'], cards=null, orderBy='createdAt', descending=true, formats=null, pageSize=10, commanders=null } ) ``` [Archidekt]: https://archidekt.com/