Welcome to the country's premier luxury online shopping API! Read on for instructions and get ready to shoppy your McFace off.
- Make sure you have Python, Flask, and a virtual environment setup and running. Setup instructions here.
- From the project root run the following:
export FLASK_APP=app
export FLASK_ENV=development
- Initialize the database:
flask init-db
- Start the server:
flask run
- Check your server output for your server address, and use that for your base url.
Take a look at the groceries. When you find some you like, create a cart and add your groceries to your cart. You can take a look at your cart at any time to see what you have in there and what it will all cost. When you're ready to check out, you may purchase the contents of your cart (and receive a receipt). All prices are assumed to be USD and are represented in cents.
GET /groceries View all groceries
GET /carts View all shopping carts
POST /carts Create a new shopping cart (this endpoint accepts no POST body)
GET /carts/:id View your cart, all groceries in your cart, purchase status, and total price of your cart.
POST /cart_groceries Add a grocery to your cart
Example post body (all fields are required):
{
"cart_id": 2,
"grocery_id": 5,
"quantity": 2
}
POST /purchase Purchase a cart of groceries. Return value is a receipt object.
Example post body (all fields are required):
{
"cart_id": 2,
"usd_paid": 500
}
GET /receipts View all receipts
DELETE /reset Reset the inventory, reset the logs, remove all carts.