MTG Deckhub is an API designed to create and view Magic the Gathering decks, users can sign up, login and store their personal decklists. They can also edit existing decks (changing the name, format, or cards), delete them and view decks and overall collection value.
Currently there is no front-end for this application.
POST /cards/fill-database
Route deisgned to initially load the cards SQL table from cards.js file. The password is defined in the .env file. Due to the file size, a reduced version of cards.js was uploaded to Github as cardsReducedSize.js. Users who want to use the complete database (over 27K cards) can download it here: Scryfall API
Parameter | Type | Description |
---|---|---|
Authorization |
string |
'Admin password_string' |
POST /sign-up
Route used to sign up to the application.
Parameter | Type | Description |
---|---|---|
name |
string |
Username |
email |
string |
User email |
password |
string |
Password |
POST /login
Allows users to login to the API, returns an object {token: token_string} which can be used to access restricted routes.
Parameter | Type | Description |
---|---|---|
email |
string |
User email |
password |
string |
Password |
GET /me/info
Returns complete user info: name, email, number of decks, collection value, array of deck objects.
Parameter | Type | Description |
---|---|---|
Authorization |
string |
'Bearer token_string' |
GET /my-decks
Returns array of user decks.
Parameter | Type | Description |
---|---|---|
Authorization |
string |
'Bearer token_string' |
POST /my-decks
Create a deck.
Parameter | Type | Description |
---|---|---|
Authorization |
string |
'Bearer token_string' |
Parameter | Type | Description |
---|---|---|
deckName |
string |
Deck name |
formatName |
string |
Format name ('standard', 'modern', 'pauper', 'commander', etc) |
cards |
array |
Array of card objects of the type {cardName, amount} |
PUT /my-decks/:deckName
Updated user deck with specified name using the given parameters. Parameters which were not sent won't be updated.
Parameter | Type | Description |
---|---|---|
Authorization |
string |
'Bearer token_string' |
Parameter | Type | Description |
---|---|---|
deckName |
string |
Deck name |
formatName |
string |
Format name ('standard', 'modern', 'pauper', 'commander', etc) |
cards |
array |
Array of card objects of the type {cardName, amount} |
DELETE /my-decks/:deckName
Deletes deck with given name from the database.
Parameter | Type | Description |
---|---|---|
Authorization |
string |
'Bearer token_string' |
-
Clone this repository
-
Download the necessary libraries with
npm i
-
(Optional) Download the Bulk Data File from Scryfall API - Oracle Cards Bulk Data File and add it to the database folder as a javascript file (cards.js), update the imported file in CardsController.js in order to use the complete database of cards (>27K) instead of the reduced one provided in this repository (~10K)
-
Create a postgreSQL database named mtgdeckhub and run the table creation queries in database/createTables.sql
-
Create and fill a .env file with the variables specified in .env.example
-
Run the server with
npm run dev
-
Send an http GET request to the route /cards/fill-database in order to initially fill the database with cards
-
Sign-up, login and send the contents of the file examples/exampleDecklist.json to the route POST /my-decks in order to create your first deck
-
Alternatively, you can run the mtgdeckhub_dump.sql file in order to create and fill the database tables with cards and decks
To be done...