This API can be used for storing and retrieving shoe data.
The RESTful API is hosted at https://shoe-catalogue-api-codex.herokuapp.com/api. Therefore, all calls to the API
should be made to that base URL, after appending any of the following URIs, depending on your intentions:
1. Want to get all shoes currently stored in the database?
-
Request Type:
GET -
URI:
/shoes
1. Want to filter shoes based on their brand?
-
Request Type:
GET -
URI:
/shoes/brand/<brand name> -
Example:
https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/brand/Nike
2. Want to filter shoes based on their size?
-
Request Type:
GET -
URI:
/shoes/size/<size> -
Example:
https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/size/9
3. Want to filter shoes based on their color?
-
Request Type:
GET -
URI:
/shoes/color/<color> -
Example:
https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/color/blue
4. Want to filter shoes based on a combination of properties?
-
Request Type:
GET -
URI:
The order of the URI for filtering follows the structure of instructions 1 - 3, including their
sequence. Brand has priority in terms of sequence over both size and color. Size has second priority,
and color URI structure is always the final element in the sequence. Always brand followed by size
followed by color.
- Example:
https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/brand/Nike/size/11/color/red
5. Want to find a shoe based on its ID?
-
Request Type:
GET -
URI:
/shoes/id/<id> -
Example:
https://shoe-catalogue-api-codex.herokuapp.com/api/shoes/id/592400e0c9c4f40004754d40
1. Want to add a new shoe to the database?
-
Request Type:
POST -
Data Type:
JSON -
Data Format:
A single JSON object representing a shoe.
{
brand : String,
size : Integer,
color : String,
in_stock : Integer // number of shoes to add to the stock
price : Integer
}
-
URI:
/shoes -
Example:
{
brand : 'Nike',
size : 10,
color : 'blue',
in_stock : 10,
price : 1200
}
2. Want to decrement shoe stock (after a sale, for example)?
-
Request Type:
POST -
Data Type:
JSON -
Data Format:
An array of object(s) representing shoes.
[
{
_id : String,
qty : Integer // number of shoes sold
},
];
-
URI:
/shoes/sold -
Example:
[
{
_id : '592400e0c9c4f40004754d40',
qty : 4
},
]
Want to contribute to and/or extend the application? Then this section's for you!
- Node & npm must be installed.
- MongoDB must be installed.
-
Fork the repository.
-
Clone the repository onto your dev machine.
-
Navigate to the project root directory.
-
Run
npm installin the project root. This will install all dependencies that are included in the package.json.
Tools that are included in this app are:
- Mongoose
- ExpressJS
- Body Parser
-
To run tests, you will need to install Mocha.. This will allow you to run the
mochacommand in the terminal in order to run your unit tests. -
Run
npm install nodemonto install nodemon. This will allow you to run the express server by using the commandnodemonin your terminal while in the project's root.
I have created a front-end application that uses this API. Consumers and developers alike may be interested in having a look at it as an example. You can find it here.