Code Monkey home page Code Monkey logo

backend-30940-proyecto-final's Introduction

E-commerce API - Backend Course - Coderhouse 30940

Simple API to do CRUD operations on products and carts.

Products

List all products
  • URL: /api/products
  • Method: GET
  • Response: 200 (OK)

JSON with products array.

{
  "products": [
    {
      "id": "1652273047326",
      "timestamp": "2022-05-11T12:44:07.326Z",
      "name": "random product",
      "description": "description for a random product",
      "stock": 5,
      "price": 150,
      "code": "coder30940",
      "photo": ""
    }
  ]
}
Add new product
  • URL: /api/products
  • Method: POST
  • Response: 201 (Created)
  • Error: 400 (Bad request)

Required Fields

Field Type
name string
description string
photo string
code string
stock number
price number

JSON with added product

{
  "added": {
    "id": "1652273047326",
    "timestamp": "2022-05-11T12:44:07.326Z",
    "name": "random product",
    "description": "description for a random product",
    "stock": 5,
    "price": 150,
    "code": "coder30940",
    "photo": ""
  }
}
Update a product
  • URL: /api/products/{product_id}
  • Method: PUT
  • Response: 204 (No content)
  • Error: 404 (Not found)

Required Fields

Field Type
name string
description string
photo string
code string
stock number
price number
Remove a product
  • URL: /api/products/{product_id}
  • Method: DELETE
  • Response: 204 (No content)
  • Error: 404 (Not found)

Cart

Create a new cart
  • URL: /api/cart/
  • Method: POST
  • Response: 201 (Created)

JSON with cart ID

{
  "cart": "1652273568738"
}
Remove a cart
  • URL: /api/cart/{cart_id}
  • Method: DELETE
  • Response: 204 (No content)
  • Error: 404 (Not Found)
List all products from cart
  • URL: /api/cart/{cart_id}/products
  • Method: GET
  • Response: 200 (OK)
  • Error: 404 (Not Found)

JSON with products array

{
  "products": [
    {
      "id": "1652273047326",
      "timestamp": "2022-05-11T12:44:07.326Z",
      "name": "random product",
      "description": "description for a random product",
      "stock": 5,
      "price": 150,
      "code": "coder30940",
      "photo": ""
    }
  ]
}
Add a new product into cart
  • URL: /api/cart/{cart_id}/products/{product_id}
  • Method: POST
  • Response: 204 (No content)
  • Error: 404 (Not Found)
Remove a product from cart
  • URL: /api/cart/{cart_id}/products/{product_id}
  • Method: DELETE
  • Response: 204 (No content)
  • Error: 404 (Not Found)

backend-30940-proyecto-final's People

Contributors

guillemartinez avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.